<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2022/11/14
 * Time: 上午11:20
 */

namespace app\common\lib\horoscope;

use app\common\lib\astrolog\Astrolog;
use app\common\model\SolarTerms;
use app\everyday\controller\Index as FortuneIndex;

/**
 * Class HoroscopeFortune
 * @package app\common\lib\horoscope
 */
class HoroscopeFortune
{
    /**
     * 单例
     * @var HoroscopeFortune
     */
    protected static $instance;

    protected $horoscopeInstance = null;

    protected $record = [];
    protected $advance = [];

    // 五行
    protected $wx = [
        '甲' => '木',
        '乙' => '木',
        '丙' => '火',
        '丁' => '火',
        '戊' => '土',
        '己' => '土',
        '庚' => '金',
        '辛' => '金',
        '壬' => '水',
        '癸' => '水',
    ];
    // 阴阳
    protected $yy = [
        '甲' => 0,
        '乙' => 1,
        '丙' => 0,
        '丁' => 1,
        '戊' => 0,
        '己' => 1,
        '庚' => 0,
        '辛' => 1,
        '壬' => 0,
        '癸' => 1,
    ];
    // 根气值
    protected $genqi = [
        '子' => [
            '癸' => 10,
        ],
        '丑' => [
            '己' => 8,
            '辛' => 3,
            '癸' => 3,
        ],
        '寅' => [
            '甲' => 9,
            '丙' => 4,
            '戊' => 2,
        ],
        '卯' => [
            '乙' => 10,
        ],
        '辰' => [
            '乙' => 3,
            '戊' => 8,
            '癸' => 3,
        ],
        '巳' => [
            '丙' => 9,
            '戊' => 4,
            '庚' => 2,
        ],
        '午' => [
            '丁' => 9.5,
            '己' => 4,
        ],
        '未' => [
            '己' => 8,
            '乙' => 3,
            '丁' => 3,
        ],
        '申' => [
            '庚' => 9,
            '戊' => 2,
            '壬' => 4,
        ],
        '酉' => [
            '辛' => 10,
        ],
        '戌' => [
            '戊' => 8,
            '辛' => 3,
            '丁' => 3,
        ],
        '亥' => [
            '壬' => 9.5,
            '甲' => 4,
        ],
    ];
    // 生
    protected $sheng = [
        '甲' => ['丙', '丁'],
        '乙' => ['丙', '丁'],
        '丙' => ['戊', '己'],
        '丁' => ['戊', '己'],
        '戊' => ['庚', '辛'],
        '己' => ['庚', '辛'],
        '庚' => ['壬', '癸'],
        '辛' => ['壬', '癸'],
        '壬' => ['甲', '丁'],
        '癸' => ['甲', '乙'],
    ];
    // 被生
    protected $beiSheng = [
        '甲' => ['壬', '癸'],
        '乙' => ['壬', '癸'],
        '丙' => ['甲', '乙'],
        '丁' => ['甲', '乙'],
        '戊' => ['丙', '丁'],
        '己' => ['丙', '丁'],
        '庚' => ['戊', '己'],
        '辛' => ['戊', '己'],
        '壬' => ['庚', '辛'],
        '癸' => ['庚', '辛'],
    ];
    // 克 key克value
    protected $ke = [
        '甲' => ['戊', '己'],
        '乙' => ['戊', '己'],
        '丙' => ['庚', '辛'],
        '丁' => ['庚', '辛'],
        '戊' => ['壬', '癸'],
        '己' => ['壬', '癸'],
        '庚' => ['甲', '乙'],
        '辛' => ['甲', '乙'],
        '壬' => ['丙', '丁'],
        '癸' => ['丙', '丁'],
    ];
    // 被克
    protected $beiKe = [
        '甲' => ['庚', '辛'],
        '乙' => ['庚', '辛'],
        '丙' => ['壬', '癸'],
        '丁' => ['壬', '癸'],
        '戊' => ['甲', '乙'],
        '己' => ['甲', '乙'],
        '庚' => ['丙', '丁'],
        '辛' => ['丙', '丁'],
        '壬' => ['戊', '己'],
        '癸' => ['戊', '己'],
    ];
    // 五行天干
    protected $wxg = [
        '木' => ['甲', '乙'],
        '火' => ['丙', '丁'],
        '土' => ['戊', '己'],
        '金' => ['庚', '辛'],
        '水' => ['壬', '癸'],
    ];
    // 月令四季五行
    protected $sjwx = [
        '子' => '水',// 冬
        '丑' => '水',// 冬
        '寅' => '木',// 春
        '卯' => '木',// 春
        '辰' => '木',// 春
        '巳' => '火',// 夏
        '午' => '火',// 夏
        '未' => '火',// 夏
        '申' => '金',// 秋
        '酉' => '金',// 秋
        '戌' => '金',// 秋
        '亥' => '水',// 冬
    ];
    // 五行克
    protected $wxKe = [
        '金' => '木',
        '水' => '火',
        '木' => '土',
        '火' => '金',
        '土' => '水',
    ];
    // 五行被克
    protected $wxBeiKe = [
        '木' => '金',
        '火' => '水',
        '土' => '木',
        '金' => '火',
        '水' => '土',
    ];
    // 五行生
    protected $wxSheng = [
        '金' => '水',
        '水' => '木',
        '木' => '火',
        '火' => '土',
        '土' => '金',
    ];
    // 五行被生
    protected $wxBeiSheng = [
        '金' => '土',
        '水' => '金',
        '木' => '水',
        '火' => '木',
        '土' => '火',
    ];
    public $shishens = [
        '甲' => [
            '比肩' => '甲',
            '劫财' => '乙',
            '食神' => '丙',
            '伤官' => '丁',
            '偏财' => '戊',
            '正财' => '己',
            '七杀' => '庚',
            '正官' => '辛',
            '偏印' => '壬',
            '正印' => '癸',
        ],
        '乙' => [
            '劫财' => '甲',
            '比肩' => '乙',
            '伤官' => '丙',
            '食神' => '丁',
            '正财' => '戊',
            '偏财' => '己',
            '正官' => '庚',
            '七杀' => '辛',
            '正印' => '壬',
            '偏印' => '癸',
        ],
        '丙' => [
            '偏印' => '甲',
            '正印' => '乙',
            '比肩' => '丙',
            '劫财' => '丁',
            '食神' => '戊',
            '伤官' => '己',
            '偏财' => '庚',
            '正财' => '辛',
            '七杀' => '壬',
            '正官' => '癸',
        ],
        '丁' => [
            '正印' => '甲',
            '偏印' => '乙',
            '劫财' => '丙',
            '比肩' => '丁',
            '伤官' => '戊',
            '食神' => '己',
            '正财' => '庚',
            '偏财' => '辛',
            '正官' => '壬',
            '七杀' => '癸',
        ],
        '戊' => [
            '七杀' => '甲',
            '正官' => '乙',
            '偏印' => '丙',
            '正印' => '丁',
            '比肩' => '戊',
            '劫财' => '己',
            '食神' => '庚',
            '伤官' => '辛',
            '偏财' => '壬',
            '正财' => '癸',
        ],
        '己' => [
            '正官' => '甲',
            '七杀' => '乙',
            '正印' => '丙',
            '偏印' => '丁',
            '劫财' => '戊',
            '比肩' => '己',
            '伤官' => '庚',
            '食神' => '辛',
            '正财' => '壬',
            '偏财' => '癸',
        ],
        '庚' => [
            '偏财' => '甲',
            '正财' => '乙',
            '七杀' => '丙',
            '正官' => '丁',
            '偏印' => '戊',
            '正印' => '己',
            '比肩' => '庚',
            '劫财' => '辛',
            '食神' => '壬',
            '伤官' => '癸',
        ],
        '辛' => [
            '正财' => '甲',
            '偏财' => '乙',
            '正官' => '丙',
            '七杀' => '丁',
            '正印' => '戊',
            '偏印' => '己',
            '劫财' => '庚',
            '比肩' => '辛',
            '伤官' => '壬',
            '食神' => '癸',
        ],
        '壬' => [
            '食神' => '甲',
            '伤官' => '乙',
            '偏财' => '丙',
            '正财' => '丁',
            '七杀' => '戊',
            '正官' => '己',
            '偏印' => '庚',
            '正印' => '辛',
            '比肩' => '壬',
            '劫财' => '癸',
        ],
        '癸' => [
            '伤官' => '甲',
            '食神' => '乙',
            '正财' => '丙',
            '偏财' => '丁',
            '正官' => '戊',
            '七杀' => '己',
            '正印' => '庚',
            '偏印' => '辛',
            '劫财' => '壬',
            '比肩' => '癸',
        ],
    ];
    // 墓库
    protected $muKu = [
        '甲' => '未',
        '乙' => '未',
        '丙' => '戌',
        '丁' => '戌',
        '戊' => '戌',
        '己' => '戌',
        '庚' => '丑',
        '辛' => '丑',
        '壬' => '辰',
        '癸' => '辰',
    ];

    /**
     * 设置档案信息
     * @param $data
     */
    public function setRecord($data)
    {
        $this->record = $data;
        return $this;
    }

    /**
     * 设置运势时间
     * @param $data
     */
    public function setAdvance($data)
    {
        if (is_string($data))
        {
            $time = strtotime($data);
            $this->advance = [
                'year' => (int)(date('Y', $time)),
                'month' => (int)(date('m', $time)),
                'day' => (int)(date('d', $time)),
                'hour' => (int)(date('H', $time)),
                'minute' => (int)(date('i', $time)),
                'timezone' => 8, // 默认北京时间
                'is_summer' => 0,
            ];
        } elseif (is_array($data))
        {
            $this->advance = $data;
        }
        return $this;
    }

    /**
     * 八字信息
     * @var array
     */
    protected $bazi = [];

    /**
     * 构造方法
     * 单例模式，私有化
     * 只能通过 getInstance 公共方法获取实例
     * HoroscopeFortune constructor.
     */
    private function __construct()
    {
    }

    /**
     * 获取实例
     * @return HoroscopeFortune
     */
    public static function getInstance(): HoroscopeFortune
    {
        if (!(self::$instance instanceof self))
        {
            self::$instance = new self();
        }
        return self::$instance;
    }

    /**
     * 设置八字
     * @param array $bazi
     */
    public function setBazi($bazi = [])
    {
        $this->bazi['bazi'] = $bazi;
        return $this;
    }

    /**
     * @param null $instance
     */
    public function setHoroscopeInstance($instance = null)
    {
        $this->horoscopeInstance = $instance;
        return $this;
    }

    public function getBazi()
    {
        return $this->bazi['bazi'];
    }

    public function getDayun()
    {
        return $this->horoscopeInstance->data['dayun_now'];
    }

    public function getLiunian()
    {
        return $this->horoscopeInstance->data['liunian_now'];
    }

    public function init()
    {
        $res = [];
        $this->horoscopeInstance = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $this->advance]);
        $this->bazi = $this->horoscopeInstance->getUserData();

        $res['bazi'] = implode('', $this->bazi['bazi']);
        $res['dayun'] = implode('', $this->horoscopeInstance->data['dayun_now']);
        $res['power'] = $this->tianganPower();
        $res['health'] = $this->jiankangPower();
//        $res['qinhe'] = $this->qinheLevel();
//        $res['guowang'] = $this->guowang();

//        $res['zhuti'] = $this->zhutiNum(0);

        $this->yongShen();

        $this->dongyingScore('正财', 1);

        $res['leida'] = $this->nianyunLeidaTouTu();

        return $res;
    }

    /**
     * 计算天干气力值
     * 衡量其是否有足够力量
     */
    public function tianganPower()
    {
        // 十天干能量分初始化为0分
        $power = $ganxiangs = $genqis = $hejus = $yunzhis = [
            '甲' => ['score' => 0],
            '乙' => ['score' => 0],
            '丙' => ['score' => 0],
            '丁' => ['score' => 0],
            '戊' => ['score' => 0],
            '己' => ['score' => 0],
            '庚' => ['score' => 0],
            '辛' => ['score' => 0],
            '壬' => ['score' => 0],
            '癸' => ['score' => 0],
        ];
        // 根气值(由于需要改值，所以存储一个)
        $genqi = $this->genqi;
        // 地支藏干表
        $canggan = $this->horoscopeInstance->param['canggan'];
        // 当前八字大运
        $dayun = $this->horoscopeInstance->data['dayun_now'] ?: [];
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];

        // 月令，运支，干象，根气，合局 按这个顺序计算

        /**
         * 月令（此项不分阴阳）
         * 五行先天得分 本气10，生气6，受生6，克气3，所克1 (此处生克表示被月令本气生克的)
         *    辰月，本气土，生气火，受生金，克气木，所克水
         * 月令所藏非本气根 +1.5
         *    乙癸（木水）为月令非本气
         * 季旺五行（非本气） +3 （季旺，寅卯辰月，季旺为木，巳午未月 季旺火，申酉戌月季旺金，亥子丑月季旺水）
         *    辰为春季，木旺
         */
        $jiwangG = $this->wxg[$this->sjwx[$this->bazi['bazi'][4]]];
        $power[$jiwangG[0]]['score'] += 3;
        $power[$jiwangG[1]]['score'] += 3;
        // 遍历4个地支的藏干
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                // 月柱藏干
                if ($k1 === 1)
                {
                    // 地支本气
                    if ($k2 === 0)
                    {
                        // 本气
                        $benqiWx = $this->wx[$v2];
                        // 生气（被月令生的天干）
                        $shengqiG = $this->beiSheng[$v2];
                        // 受生（生）
                        $shoushengG = $this->sheng[$v2];
                        // 克
                        $keG = $this->beiKe[$v2];
                        // 受克（克）
                        $shouKeG = $this->ke[$v2];

                        $power[$this->wxg[$benqiWx][0]]['score'] += 10;
                        $power[$this->wxg[$benqiWx][1]]['score'] += 10;
                        $power[$shengqiG[0]]['score'] += 6;
                        $power[$shengqiG[1]]['score'] += 6;
                        $power[$shoushengG[0]]['score'] += 6;
                        $power[$shoushengG[1]]['score'] += 6;
                        $power[$keG[0]]['score'] += 3;
                        $power[$keG[1]]['score'] += 3;
                        $power[$shouKeG[0]]['score'] += 1;
                        $power[$shouKeG[1]]['score'] += 1;
                    } else
                    {
                        $fbenqiG = $this->wxg[$this->wx[$v2]];
                        $power[$fbenqiG[0]]['score'] += 1.5;
                        $power[$fbenqiG[1]]['score'] += 1.5;
                    }
                }
            }
        }

        /**
         * 运支（仅用于大运计算，此项不分阴阳）
         * 五行先天得分 本气10，生气6，受生6，克气3，所克1
         * 月令所藏非本气根 +1.5
         * 季旺五行（非本气） +3
         */
        if (!empty($dayun))
        {
            $dayunZhi = $dayun[1] ?? '';
            foreach ($canggan[$dayunZhi] as $k1 => $v1)
            {
                if ($k1 === 0)
                {
                    // 地支本气
                    if ($k2 === 0)
                    {
                        // 本气
                        $benqiWx = $this->wx[$v1];
                        // 生气（被月令生的天干）
                        $shengqiG = $this->beiSheng[$v1];
                        // 受生（生）
                        $shoushengG = $this->sheng[$v1];
                        // 克
                        $keG = $this->beiKe[$v1];
                        // 受克（克）
                        $shouKeG = $this->ke[$v1];
                        $power[$this->wxg[$benqiWx][0]]['score'] += 10;
                        $power[$this->wxg[$benqiWx][1]]['score'] += 10;
                        $power[$shengqiG[0]]['score'] += 6;
                        $power[$shengqiG[1]]['score'] += 6;
                        $power[$shoushengG[0]]['score'] += 6;
                        $power[$shoushengG[1]]['score'] += 6;
                        $power[$keG[0]]['score'] += 3;
                        $power[$keG[1]]['score'] += 3;
                        $power[$shouKeG[0]]['score'] += 1;
                        $power[$shouKeG[1]]['score'] += 1;

                        $yunzhis[$this->wxg[$benqiWx][0]]['score'] += 10;
                        $yunzhis[$this->wxg[$benqiWx][1]]['score'] += 10;
                        $yunzhis[$shengqiG[0]]['score'] += 6;
                        $yunzhis[$shengqiG[1]]['score'] += 6;
                        $yunzhis[$shoushengG[0]]['score'] += 6;
                        $yunzhis[$shoushengG[1]]['score'] += 6;
                        $yunzhis[$keG[0]]['score'] += 3;
                        $yunzhis[$keG[1]]['score'] += 3;
                        $yunzhis[$shouKeG[0]]['score'] += 1;
                        $yunzhis[$shouKeG[1]]['score'] += 1;
                    } else
                    {
                        $fbenqiG = $this->wxg[$this->wx[$v1]];
                        $power[$fbenqiG[0]]['score'] += 1.5;
                        $power[$fbenqiG[1]]['score'] += 1.5;

                        $yunzhis[$fbenqiG[0]]['score'] += 1.5;
                        $yunzhis[$fbenqiG[1]]['score'] += 1.5;
                    }
                }
            }
            $jiwangG = $this->wxg[$this->sjwx[$dayunZhi]];
            $power[$jiwangG[0]]['score'] += 3;
            $power[$jiwangG[1]]['score'] += 3;

            $yunzhis[$jiwangG[0]]['score'] += 3;
            $yunzhis[$jiwangG[1]]['score'] += 3;
        }

        /**
         * 干象
         * (不管透不透干都需要检查是否受生克，修改根气值)
         * 观察各根同柱天干，如受其生则此根得分加1/5，如受其克则此根得分减1/5
         * 如该干透干
         *   +3*透干次数（需斟酌）
         */
        $touganCount = array_count_values($tiangan);
        foreach ($power as $k1 => $v1)
        {
            if (isset($touganCount[$k1]) && $touganCount[$k1] > 0)
            {
                $power[$k1]['score'] += (3 * $touganCount[$k1]);
                $ganxiangs[$k1]['score'] += (3 * $touganCount[$k1]);
            }
        }
        // 遍历同柱地支藏干 修改根气值
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                // 受同柱天干所生
                if (in_array($v2, $this->sheng[$tiangan[$k1]], true))
                {
                    $genqi[$v1][$v2] *= 1.2;
                }// 受同柱天干所克
                elseif (in_array($v2, $this->ke[$tiangan[$k1]], true))
                {
                    $genqi[$v1][$v2] *= 0.8;
                }
            }
        }

        /**
         * 根气（此处需要看阴阳五行）
         *  如该干透出天干，其坐下根得分*1.5
         *    如为同性根，+根气值
         *    如为异性根，+根气值*0.7（如该干透干改为*0.9）
         */
        // 遍历地支
        foreach ($dizhi as $k1 => $v1)
        {
            // 遍历地支藏干
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                // 藏干
                $cangganWuxingGan = $this->wxg[$this->wx[$v2]];
                $x1 = $x2 = 1;
                // 异性根
                if ($cangganWuxingGan[0] !== $v2)
                {
                    $x1 = 0.7;
                }
                if (in_array($cangganWuxingGan[0], $tiangan, true))
                {
                    if ($x1 === 0.7)
                    {
                        $x1 = 0.9;
                    }
                    $x1 *= 1.5;
                }
                // 异性根
                if ($cangganWuxingGan[1] !== $v2)
                {
                    $x2 = 0.7;
                }
                if (in_array($cangganWuxingGan[1], $tiangan, true))
                {
                    if ($x2 === 0.7)
                    {
                        $x2 = 0.9;
                    }
                    $x2 *= 1.5;
                }
                // 藏的阳干
                $genqi[$v1][$v2] *= $x1;
//                $genqi[$v1][$cangganWuxingGan[0]] *= $x1;
//                $genqi[$v1][$cangganWuxingGan[1]] *= $x2;
                $power[$v2]['score'] += $genqi[$v1][$v2];
                $genqis[$v2]['score'] += $genqi[$v1][$v2];
            }
        }

        // 戌中丁 2.4，寅中丙 3.2，未中丁 3。月令7.5；
        // 根气，丙=3.2+2.4*0.7+3*0.7=3.2+1.68+2.1=6.98，丁=3.2*0.7+2.4+3=2.24+5.4=7.64

        /**
         * 合局
         * 如地支有三合局，该五行阴阳干均+5
         */
        $sanhe1 = $this->horoscopeInstance->is_sanhe($dizhi[0], $dizhi[1], $dizhi[2]);
        if ($sanhe1 !== '')
        {
            foreach ($this->wxg[$sanhe1] as $k1 => $v1)
            {
                $power[$v1]['score'] += 5;
                $hejus[$v1]['score'] += 5;
            }
        }
        $sanhe2 = $this->horoscopeInstance->is_sanhe($dizhi[0], $dizhi[1], $dizhi[3]);
        if ($sanhe2 !== '')
        {
            foreach ($this->wxg[$sanhe2] as $k1 => $v1)
            {
                $power[$v1]['score'] += 5;
                $hejus[$v1]['score'] += 5;
            }
        }
        $sanhe3 = $this->horoscopeInstance->is_sanhe($dizhi[1], $dizhi[2], $dizhi[3]);
        if ($sanhe3 !== '')
        {
            foreach ($this->wxg[$sanhe3] as $k1 => $v1)
            {
                $power[$v1]['score'] += 5;
                $hejus[$v1]['score'] += 5;
            }
        }


        /**
         * 分级（不考虑月令、运支加分）
         * 无根为0级 弱
         * 有根但分数低于7，1级 弱
         * 得分大于7小于15，2级 较旺
         * 得分大于15小于21，3级 旺
         * 得分大于21小于28，4级 过旺
         * 得分大于28，5级 极旺
         */
        $res = [];
        foreach ($power as $k1 => $v1)
        {
            if ($v1['score'] === 0)
            {
                $level = 0;
            } elseif ($v1['score'] < 7)
            {
                $level = 1;
            } elseif ($v1['score'] < 15)
            {
                $level = 2;
            } elseif ($v1['score'] < 21)
            {
                $level = 3;
            } elseif ($v1['score'] < 28)
            {
                $level = 4;
            } else
            {
                $level = 4;
                // 某十神或某五行极旺，需月令本气不是克制该十神的五行，且克该十神的五行不明现
                $yueBenqiGan = $canggan[$dizhi[1]][0];
                $keShishenGan = $this->beiKe[$k1];
                if (!in_array($yueBenqiGan, $keShishenGan, true))
                {
                    $dizhiBenqiList = [$canggan[$dizhi[0]][0], $canggan[$dizhi[1]][0], $canggan[$dizhi[2]][0], $canggan[$dizhi[3]][0]];
                    if (!in_array($k1, $tiangan, true) && !in_array($k1, $dizhiBenqiList, true))
                    {
                        $level = 5;
                    }
                }
            }
            $res[$k1] = [
                'score' => $v1['score'],
                'level' => $level
            ];
        }
        return $res;
    }

    /**
     * 计算健康值
     * @param int $type 0=>本命,1=>大运,2=>流年
     * @param array $dayun
     * @param array $liunian
     * @return array
     */
    protected function jiankangPower($type = 0, $dayun = [], $liunian = [])
    {
        // 衡量其是否被破坏，能否正常发挥，如不能正常发挥则会导致相关问题
        /**
         * sheng 受生
         * ke 受克
         * ming 生命
         */
        $power = [
            '甲' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '乙' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '丙' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '丁' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '戊' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '己' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '庚' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '辛' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '壬' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
            '癸' => ['sheng' => 0, 'ke' => 0, 'ming' => 0],
        ];
        $tianganList = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'];
        /**
         * 生克系数
         * 同性生、异性克 0.4
         * 异性生、同性克 0.7
         */
        $keX = [0.7, 0.4];
        $shengX = [0.4, 0.7];
        /**
         * 各干受克（未考虑气力）
         * 受克包括，天干克天干，地支克地支，干覆支，支截干，每个天干或地支单位受克一次则计算一次
         * 受克强弱有距离影响，相邻柱距离1，隔柱距离2，再隔一柱距离3
         * 地支克地支有关系系数影响
         * 合1，冲1，拱0.7，刑穿0.7，其它0.3
         * 同性相克
         *  天干：10/距离*生克系数
         *  地支：（受克根根气值+施克根根气值）/距离*关系系数*生克系数*0.5
         *  干覆支：受克根根气值*0.8*生克系数
         *  支截干：施克根根气值*0.8*生克系数
         *  系数暂定
         * 各干受生（未考虑气力）
         * 受生包括天干生天干，地支生地支，天生地，地生天，每个地支或天干单位受生一次则计算一次
         * 受生强弱有距离影响，相邻柱距离1，隔柱距离2，再隔一柱距离3
         * 地支生地支有关系系数影响
         * 合1，拱1，其它0.3
         * 地支生方只能是本气，中余气没有生的权力，被生五行的根与生方五行的根都在生方地支时除外
         * 异性相生
         *  天干：10/距离*生克系数
         *  地支：（受生根根气值+施生根根气值）/距离*关系系数*生克系数
         *  干生支：受生根根气值*0.8*生克系数
         *  支生干：施生根根气值*0.8*生克系数
         *  系数暂定
         */
        $bazi = $this->bazi['bazi'];
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        $count = 4;
        if ($type === 1)
        {
            if (!empty($dayun))
            {
                $tiangan[] = $dayun[0];
                $dizhi[] = $dayun[1];
                $count = 5;
            }
        } elseif ($type === 2)
        {
            if (!empty($dayun))
            {
                $tiangan[] = $dayun[0];
                $dizhi[] = $dayun[1];
            }
            if (!empty($liunian))
            {
                $tiangan[] = $liunian[0];
                $dizhi[] = $liunian[1];
            }
            $count = count($tiangan);
        }
        $rx1 = ['合' => 1, '冲' => 1, '拱' => 0.7, '刑' => 0.7, '穿' => 0.7, '其他' => 0.3];
        $rx2 = ['合' => 1, '冲' => 0.3, '拱' => 1, '刑' => 0.3, '穿' => 0.3, '其他' => 0.3];
        // 遍历天干 10/距离*生克系数
        for ($i = 0; $i < $count; $i++)
        {
            for ($j = $i + 1; $j < $count; $j++)
            {
                // 距离
                $instance = $j - $i;
                if ($i > 3 || $j > 3)
                {
                    $instance = 1;
                }
                // $i克$j
                $index1_1 = array_search($tiangan[$j], $this->ke[$tiangan[$i]], true);
                // $j克$i
                $index1_2 = array_search($tiangan[$j], $this->beiKe[$tiangan[$i]], true);
                // $i生$j
                $index2_1 = array_search($tiangan[$j], $this->sheng[$tiangan[$i]], true);
                // $j生$i
                $index2_2 = array_search($tiangan[$j], $this->beiSheng[$tiangan[$i]], true);
                // 计算受克天干计分项
                if ($index1_1 !== false || $index1_2 !== false)
                {
                    if ($this->yy[$tiangan[$i]] !== $this->yy[$tiangan[$j]])
                    {
                        // 异性
                        $kx = $keX[1];
                    } else
                    {
                        // 同性
                        $kx = $keX[0];
                    }
                    $ks = 10 / $instance * $kx;
                    // 受克者加分
                    if ($index1_1 !== false)
                    {
                        $power[$tiangan[$j]]['ke'] += $ks;
                    } else
                    {
                        $power[$tiangan[$i]]['ke'] += $ks;
                    }
                }
                if ($index2_1 !== false || $index2_2 !== false)
                {
                    // 异性
                    if (array_search($tiangan[$i], $tianganList, true) % 2 !== array_search($tiangan[$j], $tianganList, true) % 2)
                    {
                        $sx = $shengX[1];
                    } else
                    {
                        // 同性相克
                        $sx = $shengX[0];
                    }
                    $ss = 10 / $instance * $sx;
                    // 受生者加分
                    if ($index2_1 !== false)
                    {
                        $power[$tiangan[$j]]['sheng'] += $ss;
                    } else
                    {
                        $power[$tiangan[$i]]['sheng'] += $ss;
                    }
                }
            }
        }
        // 地支：（受克根根气值+施克根根气值）/距离*关系系数*生克系数*0.5
        $canggan = $this->horoscopeInstance->param['canggan'];
        for ($i = 0; $i < $count; $i++)
        {
            for ($j = $i + 1; $j < $count; $j++)
            {
                // 遍历该柱地支藏干
                foreach ($canggan[$dizhi[$i]] as $k1 => $v1)
                {
                    // 遍历该柱地支藏干
                    foreach ($canggan[$dizhi[$j]] as $k2 => $v2)
                    {
                        // 距离
                        $instance = $j - $i;
                        if ($i > 3 || $j > 3)
                        {
                            $instance = 1;
                        }
                        $isSame = 0; // 默认同性
                        // 异性
                        if ($this->yy[$tiangan[$i]] !== $this->yy[$tiangan[$j]])
                        {
                            $isSame = 1;
                        }
                        // 关系系数
                        $rel = $this->getDizhiReleation($dizhi[$i], $dizhi[$j]);
                        $score = ($this->genqi[$dizhi[$i]][$v1] + $this->genqi[$dizhi[$j]][$v2]) / $instance;
                        if (in_array($v2, $this->ke[$v1], true))
                        {
                            // $v1克$v2 地支：（受克根根气值+施克根根气值）/距离*关系系数*生克系数*0.5
                            $power[$v2]['ke'] += $score * $keX[$isSame] * $rx1[$rel] * 0.5;
                        } elseif (in_array($v1, $this->ke[$v2], true))
                        {
                            // $v2克$v1 地支：（受克根根气值+施克根根气值）/距离*关系系数*生克系数*0.5
                            $power[$v1]['ke'] += $score * $keX[$isSame] * $rx1[$rel] * 0.5;
                        } elseif (in_array($v2, $this->sheng[$v1], true))
                        {
                            // $v1生$v2 地支：（受生根根气值+施生根根气值）/距离*关系系数*生克系数
                            $power[$v2]['sheng'] += $score * $shengX[$isSame] * $rx2[$rel] * 0.5;
                        } elseif (in_array($v1, $this->sheng[$v2], true))
                        {
                            // $v2生$v1 地支：（受生根根气值+施生根根气值）/距离*关系系数*生克系数
                            $power[$v1]['sheng'] += $score * $shengX[$isSame] * $rx2[$rel] * 0.5;
                        }
                    }
                }
            }
        }
        // 遍历四柱
        for ($i = 0; $i < $count; $i++)
        {
            // 计算生命值 天干上的干生命值为10
            $power[$tiangan[$i]]['ming'] += 10;
            // 遍历地支藏干
            foreach ($canggan[$dizhi[$i]] as $k1 => $v1)
            {
                // 计算生命值 地支里的干生命值为其根气值
                $power[$v1]['ming'] += $this->genqi[$dizhi[$i]][$v1];

                /**
                 * 计算总生命值时加上月令的加权值，
                 *  月令本气五行10，
                 *  月令生5，
                 *  生月令2，
                 *  克月令0，
                 *  月令克0，
                 *  季旺但非月令本气五行+6，
                 *  月令藏干但非本气非季旺+2
                 */
                // 月令
                if ($i === 1)
                {
                    // 月令本气
                    if ($k1 === 0)
                    {
                        $wxg = $this->wxg[$this->wx[$v1]];
                        $power[$wxg[0]]['ming'] += 10;
                        $power[$wxg[1]]['ming'] += 10;
                        // 月令生
                        $power[$this->sheng[$v1][0]]['ming'] += 5;
                        $power[$this->sheng[$v1][1]]['ming'] += 5;
                        // 生月令
                        $power[$this->beiSheng[$v1][0]]['ming'] += 2;
                        $power[$this->beiSheng[$v1][1]]['ming'] += 2;
                        // 月令克0
//                        $power[$this->ke[$v1][0]]['ming'] -= 3;
//                        $power[$this->ke[$v1][1]]['ming'] -= 3;
                    } else
                    {
                        if (in_array($v1, $this->wxg[$this->sjwx[$dizhi[$i]]], true))
                        {
                            $power[$v1]['ming'] += 6;
                        } else
                        {
                            $power[$v1]['ming'] += 2;
                        }
                    }
                }

                // 检查同柱天干与地支藏干关系
                $isSame = 0; // 默认同性
                // 异性
                if ($this->yy[$tiangan[$i]] !== $this->yy[$v1])
                {
                    $isSame = 1;
                }
                if (in_array($v1, $this->ke[$tiangan[$i]], true))
                {
                    // 天干克地支 干覆支：受克根根气值*0.8*生克系数
                    $power[$v1]['ke'] += $this->genqi[$dizhi[$i]][$v1] * 0.8 * $keX[$isSame];
                } elseif (in_array($v1, $this->sheng[$tiangan[$i]], true))
                {
                    // 天干生地支 干生支：受生根根气值*0.8*生克系数
                    $power[$v1]['sheng'] += $this->genqi[$dizhi[$i]][$v1] * 0.8 * $shengX[$isSame];
                } elseif ($k1 === 0)
                {
                    if (in_array($tiangan[$i], $this->ke[$v1], true))
                    {
                        // 地支克天干 支截干：施克根根气值*0.8*生克系数
                        $power[$tiangan[$i]]['ke'] += $this->genqi[$dizhi[$i]][$v1] * 0.8 * $keX[$isSame];
                    } elseif (in_array($tiangan[$i], $this->sheng[$v1], true))
                    {
                        // 地支生天干 支生干：施生根根气值*0.8*生克系数 (只看本气)
                        $power[$tiangan[$i]]['sheng'] += $this->genqi[$dizhi[$i]][$v1] * 0.8 * $shengX[$isSame];
                    }
                }
            }
        }
        /**
         * 健康值
         * 某干健康值=该干最终受克值/（该干生命值+该干最终受生值）
         * 值越高越不健康
         * 某干实力值=该干生命值+该干最终受生值-该干最终受克值
         * 某干综合实力值=某干实力值+某干劫财实力值*0.7
         * 判定：偏神压正
         *  某干为财官印食比正神，其健康值高于1，其偏神健康值低于1且偏神实力值大于正神
         * 某干真正实力值=某干综合实力值-该干七杀综合实力值
         */
        $res = [];
        foreach ($power as $k => $v)
        {
            $shengming = $v['sheng'] + $v['ming'];
            // 1-现有健康值，最大取1，最小取零
            $res[$k]['jiankang'] = $shengming <= 0 ? 0.5 : 1 - ($v['ke'] / $shengming);
            if ($res[$k]['jiankang'] > 1)
            {
                $res[$k]['jiankang'] = 1;
            } elseif ($res[$k]['jiankang'] < 0)
            {
                $res[$k]['jiankang'] = 0;
            }
            $res[$k]['shili'] = $shengming - $v['ke'];
            $res[$k]['sheng'] = $v['sheng'];
            $res[$k]['ke'] = $v['ke'];
            $res[$k]['ming'] = $v['ming'];
        }
        foreach ($power as $k => $v)
        {
            // 某干劫财 为异性五行
            $index = array_search($k, $tianganList, true);
            // 奇数为阴 取上一个阳性的为劫财
            if ($index % 2 === 1)
            {
                $jie = $tianganList[$index - 1];
            } else
            {
                $jie = $tianganList[$index + 1];
            }
            $res[$k]['zong_shili'] = $res[$k]['shili'] + $res[$jie]['shili'] * 0.7;
        }
        foreach ($power as $k => $v)
        {
            // 某干真正实力值=某干综合实力值-该干七杀综合实力值
            // 同性克我为七杀
            $index = array_search($k, $tianganList, true) + 6;
            if ($index > 9)
            {
                $index -= 10;
            }
            $res[$k]['zhen_shili'] = $res[$k]['zong_shili'] - $res[$tianganList[$index]]['zong_shili'];
        }
        return $res;
    }

    /**
     * 计算亲和等级
     * @param array $dayun
     * @return int
     */
    protected function qinheLevel($dayun = [])
    {
        /**
         * 亲和（大运）
         * 1级
         *  运干或运支合日干或日支
         *  运支不受原局冲穿
         *  运干不见原局正克（同性）
         * 2级
         *  运干或运支合日干或日支
         *  运支有原局冲穿但非时支，如果是时支则为辰戌丑未
         *  如果运干有原局正克，需有原局天干对运干正生或合
         * 3级
         *  运支合日支但不满足1级2级条件，或运支拱日支且原局无冲
         * 4级
         *  运支拱日支但原局有冲，或运支合时支且原局无冲
         * 5级
         *  非1234，运支拱合日干禄（禄=禄神）
         * 6级
         *  其它
         */
        $shensha = $this->horoscopeInstance->param['shensha'];
//        // 当前八字大运
//        $dayun = $this->horoscopeInstance->data['dayun_now'];
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        // 运干或运支合日干或日支 (运干五合日干\运支六合日支\运支暗合日支)
        $x1_1 = $this->horoscopeInstance->is_wuhe($dayun[0], $tiangan[2]) || $this->horoscopeInstance->is_liuhe($dayun[1], $dizhi[2]) || $this->horoscopeInstance->is_anhe($dayun[1], $dizhi[2]);
        // 运支不受原局冲穿
        $x1_2 = false;
        foreach ($dizhi as $k1 => $v1)
        {
            if ($this->horoscopeInstance->is_liuchong($dayun[1], $v1) || $this->horoscopeInstance->is_liuhai($dayun[1], $v1))
            {
                $x1_2 = true;
                break;
            }
        }
        // 运干不见原局正克（同性）
        $x1_3 = false;
        foreach ($tiangan as $k1 => $v1)
        {
            $y = $this->yy[$v1];
            if ($this->ke[$v1][$y] === $dayun[0])
            {
                $x1_3 = true;
                break;
            }
        }
        if ($x1_1 && !$x1_2 && $x1_3)
        {
            return 1;
        }
        // 运干或运支合日干或日支
        $x2_1 = $x1_1;
        // 运支有原局冲穿但非日时支，如果是时支则为辰戌丑未
        $x2_2 = false;
        foreach ($dizhi as $k1 => $v1)
        {
            if ($this->horoscopeInstance->is_liuchong($dayun[1], $v1) || $this->horoscopeInstance->is_liuhai($dayun[1], $v1))
            {
                if ((!in_array($k1, [2, 3], true)) || ($k1 === 3 && in_array($v1, ['辰', '戌', '丑', '未'], true)))
                {
                    $x2_2 = true;
                    break;
                }
            }
        }
        // 如果运干与原局有正克，需有原局天干对运干正生或合
        $x2_3 = false;
        $x2_4 = false;
        foreach ($tiangan as $k1 => $v1)
        {
            $y = $this->yy[$v1];
            if ($x2_3 === false && $this->ke[$v1][$y] === $dayun[0])
            {
                $x2_3 = true;
            }
            if ($x2_4 === false && ($this->sheng[$v1][$y] === $dayun[0] || $this->horoscopeInstance->is_wuhe($v1, $dayun[0])))
            {
                $x2_4 = true;
            }
        }
        if ($x2_1 && $x2_2 && $x2_3 && $x2_4)
        {
            return 2;
        }
        // 运支合日支但不满足1级2级条件，或运支拱日支且运支与原局无冲
        $x3_1 = $this->horoscopeInstance->is_liuhe($dayun[1], $dizhi[2]) || $this->horoscopeInstance->is_anhe($dayun[1], $dizhi[2]);
        if ($x3_1)
        {
            return 3;
        }
        $x3_2 = false;
        if ($this->horoscopeInstance->is_gong($dayun[1], $dizhi[2]))
        {
            $x3_2 = true;
        }
        $x3_3 = false;
        for ($i = 0; $i < 4; $i++)
        {
            if ($this->horoscopeInstance->is_liuchong($dizhi[$i], $dayun[1]))
            {
                $x3_3 = true;
                break;
            }
        }
        if ($x3_2 && !$x3_3)
        {
            return 3;
        }
        // 运支拱日支但与原局有冲，或运支合时支且与原局无冲
        if ($x3_2 && $x3_3)
        {
            return 4;
        }
        if (!$x3_3 && ($this->horoscopeInstance->is_liuhe($dayun[1], $dizhi[3]) || $this->horoscopeInstance))
        {
            return 4;
        }
        // 非1234，运支拱合日干禄（禄=禄神）
        $riganLu = $shensha['禄神'][$tiangan[2]];
        if ($this->horoscopeInstance->is_gong($dayun[1], $riganLu)
            || $this->horoscopeInstance->is_liuhe($dayun[1], $riganLu)
            || $this->horoscopeInstance->is_anhe($dayun[1], $riganLu))
        {
            return 5;
        }
        return 6;
    }

    /**
     * 计算五行过旺
     * 返回过旺的五行或者为空
     */
    public function guowang()
    {
        /**
         * 过旺
         *  该五行本气根两个以上，且，本气根+土藏气总数大于等于三个，且，月令为该五行本气或土藏气，且，克该五行的五行如有本气根则天干不超过两次透干
         *  该五行的本气根一个以上，且本气根土藏气总数大于等于三个，且，地支无克该五行的本气根，且，天干有该五行透干无克该五行的透干
         */
        $res = [
            '金' => ['cang_num' => 0, 'benqi_cang_num' => 0, 'tu_cang_num' => 0, 'is_yue_benqi' => false,],
            '木' => ['cang_num' => 0, 'benqi_cang_num' => 0, 'tu_cang_num' => 0, 'is_yue_benqi' => false,],
            '土' => ['cang_num' => 0, 'benqi_cang_num' => 0, 'tu_cang_num' => 0, 'is_yue_benqi' => false,],
            '水' => ['cang_num' => 0, 'benqi_cang_num' => 0, 'tu_cang_num' => 0, 'is_yue_benqi' => false,],
            '火' => ['cang_num' => 0, 'benqi_cang_num' => 0, 'tu_cang_num' => 0, 'is_yue_benqi' => false,],
        ];
        // 五行被克
        $wxbk = [
            '木' => '金',
            '土' => '木',
            '水' => '土',
            '火' => '水',
            '金' => '火'
        ];
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 天干透出次数
        $tianganTouNum = [
            '甲' => 0,
            '乙' => 0,
            '丙' => 0,
            '丁' => 0,
            '戊' => 0,
            '己' => 0,
            '庚' => 0,
            '辛' => 0,
            '壬' => 0,
            '癸' => 0,
        ];
        foreach ($tiangan as $k1 => $v1)
        {
            $tianganTouNum[$v1]++;
        }
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        $canggan = $this->horoscopeInstance->param['canggan'];
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                // 藏干数
                $res[$this->wx[$v2]]['cang_num']++;
                // 本气
                if ($k2 === 0)
                {
                    // 本气藏干数
                    $res[$this->wx[$v2]]['benqi_cang_num']++;
                    if ($k1 === 1)
                    {
                        // 是月令本气五行
                        $res[$this->wx[$v2]]['is_yue_benqi'] = true;
                    }
                } else
                {
                    // 土藏气
                    if (in_array($v1, ['辰', '戌', '丑', '未'], true))
                    {
                        $res[$this->wx[$v2]]['tu_cang_num']++;
                    }
                }
            }
        }
        foreach ($res as $k1 => $v1)
        {
            $x1_1 = $x1_2 = $x1_3 = $x1_4 = false;
            // 该五行本气根两个以上
            if ($v1['benqi_cang_num'] >= 2)
            {
                $x1_1 = true;
            }
            // 本气根+土藏气总数大于等于三个
            if ($v1['benqi_cang_num'] + $v1['tu_cang_num'] >= 3)
            {
                $x1_2 = true;
            }
            // 月令为该五行本气或土藏气
            if ($v1['is_yue_benqi'] || in_array($dizhi[1], ['辰', '戌', '丑', '未'], true))
            {
                $x1_3 = true;
            }
            // 克该五行的五行如有本气根则天干不超过两次透干
            if ($res[$wxbk[$k1]]['benqi_cang_num'] <= 0)
            {
                $x1_4 = true;
            } else
            {
                $kewx = $this->wxg[$wxbk[$k1]];
                if ($tianganTouNum[$kewx[0]] + $tianganTouNum[$kewx[1]] > 2)
                {
                    $x1_4 = true;
                }
            }
            if ($x1_1 && $x1_2 && $x1_3 && $x1_4)
            {
                return $k1;
            }
            // 该五行的本气根一个以上，且本气根土藏气总数大于等于三个，且，地支无克该五行的本气根，且，天干有该五行透干无克该五行的透干
            $x2_1 = $x2_2 = $x2_3 = $x2_4 = false;
            if ($v1['benqi_cang_num'] >= 1)
            {
                $x2_1 = true;
            }
            // 本气根土藏气总数大于等于三个
            $x2_2 = $x1_2;
            // 地支无克该五行的本气根
            if ($res[$wxbk[$k1]]['benqi_cang_num'] <= 0)
            {
                $x2_3 = true;
            }
            // 天干有该五行透干,无克该五行的透干
            $wxg = $this->wxg[$k1];
            $kewx = $this->wxg[$wxbk[$k1]];
            if ($tianganTouNum[$wxg[0]] + $tianganTouNum[$wxg[1]] > 0 && $tianganTouNum[$kewx[0]] + $tianganTouNum[$kewx[1]] < 0)
            {
                $x2_4 = true;
            }
            if ($x2_1 && $x2_2 && $x2_3 && $x2_4)
            {
                return $k1;
            }
        }

        return '';
    }

    /**
     * 主题计数
     * @param int $type 0=>本命,1=>大运,2=>流年
     * @param array $dayun
     * @param array $liunian
     * @param array $dataTypes
     * @return array
     */
    protected function zhutiNum($type = 0, $dayun = [], $liunian = [], $dataTypes = [])
    {
        $res = [];
        $sex = (int)$this->record['type'] === 1 ? 1 : 2;
        if (empty($dataTypes) || in_array('fuqin', $dataTypes, true))
        {
            $res['fuqin'] = $this->zhuti($this->bazi['bazi'][1], $this->bazi['bazi'][2], ['正财', '偏财'], $dayun, $liunian, $type);
        }
        if (empty($dataTypes) || in_array('muqin', $dataTypes, true))
        {
            $res['muqin'] = $this->zhuti($this->bazi['bazi'][1], $this->bazi['bazi'][2], ['正印', '偏印'], $dayun, $liunian, $type);
        }
        if ($sex === 2)
        {
            if (empty($dataTypes) || in_array('zinv', $dataTypes, true))
            {
                $res['zinv'] = $this->zhuti($this->bazi['bazi'][7], $this->bazi['bazi'][8], ['正官', '七杀'], $dayun, $liunian, $type);
            }
            if (empty($dataTypes) || in_array('hunlian', $dataTypes, true))
            {
                $res['hunlian'] = $this->zhuti('', $this->bazi['bazi'][6], ['正官', '七杀'], $dayun, $liunian, $type);
            }
        } else
        {
            if (empty($dataTypes) || in_array('zinv', $dataTypes, true))
            {
                $res['zinv'] = $this->zhuti($this->bazi['bazi'][7], $this->bazi['bazi'][8], ['食神', '伤官'], $dayun, $liunian, $type);
            }
            if (empty($dataTypes) || in_array('hunlian', $dataTypes, true))
            {
                $res['hunlian'] = $this->zhuti('', $this->bazi['bazi'][6], ['正财', '偏财'], $dayun, $liunian, $type);
            }
        }
        if (empty($dataTypes) || in_array('xiongmei', $dataTypes, true))
        {
            $res['xiongmei'] = $this->zhuti($this->bazi['bazi'][3], $this->bazi['bazi'][4], ['比肩', '劫财'], $dayun, $liunian, $type);
        }
        if (empty($dataTypes) || in_array('gongzuo', $dataTypes, true))
        {
            $res['gongzuo1'] = $this->zhuti('', '', ['正官', '七杀'], $dayun, $liunian, $type);
            $res['gongzuo2'] = $this->zhuti('', '', ['正印', '偏印'], $dayun, $liunian, $type);
        }
        if (empty($dataTypes) || in_array('zaibing', $dataTypes, true))
        {
            $res['zaibing'] = $this->zhuti('', '', ['七杀'], $dayun, $liunian, $type);
        }
        if (empty($dataTypes) || in_array('caifu', $dataTypes, true))
        {
            $res['caifu'] = $this->zhuti('', '', ['正财', '偏财'], $dayun, $liunian, $type);
        }
        if (empty($dataTypes) || in_array('xueye', $dataTypes, true))
        {
            $res['xueye'] = $this->zhuti('', '', ['正印', '偏印'], $dayun, $liunian, $type);
        }
        return $res;
    }

    /**
     * 主题分值计算
     * @param string $gan 宫干
     * @param string $zhi 宫支
     * @param array $xing 星
     * @param array $dayun 大运
     * @param array $liunian 流年
     * @param int $type 0=>本命,1=>大运,2=>流年
     * @return float[]
     */
    protected function zhuti($gan = '', $zhi = '', $xing = [], $dayun = [], $liunian = [], $type = 0)
    {
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        $shishen = $this->horoscopeInstance->param['shishen'];
        $canggan = $this->horoscopeInstance->param['canggan'];
        $shensha = $this->horoscopeInstance->param['shensha'];
        if ($type === 1)
        {
            $yun = empty($dayun) ? [] : $dayun;
        } else
        {
            if (!empty($dayun))
            {
                $tiangan[] = $dayun[0];
                $dizhi[] = $dayun[1];
            }
            $yun = $liunian;
        }
        $gongDongtai = $gongFumian = 0;
        /**
         * 宫干 (禄 => 宫干的禄，关系主体为大运/流年)
         *  干出现 动态值1.5
         *  干禄出现 1.5
         *  合干 1
         *  正克干 负面值1  (大运克宫干)
         *  合禄（包括暗合） 动态值1
         *  冲禄 动态值1 负面值1
         *  拱禄 动态值0.6
         *  刑穿禄 动态值0.6 负面值0.6
         */
        // 若宫干存在，则记分
        if ($gan !== '' && !empty($yun))
        {
            $lushen = $shensha['禄神'][$gan];
            // 干出现
            if ($gan === $yun[0])
            {
                $gongDongtai += 1.5;
            }
            // 干禄出现
            if ($lushen === $yun[0])
            {
                $gongDongtai += 1.5;
            }
            // 合干
            if ($this->horoscopeInstance->is_wuhe($gan, $yun[0]))
            {
                $gongDongtai++;
            }
            // 正克干 (同性克)
            if ($this->yy[$gan] === $this->yy[$yun[0]] && in_array($gan, $this->ke[$yun[0]], true))
            {
                $gongFumian++;
            }
            // 合禄（包括暗合）
            if ($this->horoscopeInstance->is_liuhe($yun[1], $lushen) || $this->horoscopeInstance->is_anhe($yun[1], $lushen))
            {
                $gongDongtai++;
            }
            // 冲禄 动态值1 负面值1
            if ($this->horoscopeInstance->is_liuchong($yun[1], $lushen))
            {
                $gongDongtai++;
                $gongFumian++;
            }
            // 拱禄 动态值0.6
            if ($this->horoscopeInstance->is_gong($yun[1], $lushen))
            {
                $gongDongtai += 0.6;
            }
            // 刑穿禄 动态值0.6 负面值0.6
            if ($this->horoscopeInstance->is_xing($yun[1], $lushen)
                || $this->horoscopeInstance->is_liuhai($yun[1], $lushen))
            {
                $gongDongtai += 0.6;
                $gongFumian += 0.6;
            }
        }

        /**
         * 宫支
         * 支出现 动态值1.5
         * 透干出现（干禄是该支） 动态值 1.5
         * 透干受合 动态值 1
         * 透干受正克 负面值1
         * 合支 动态值1
         * 冲支 动态值1 负面值1
         * 拱支 动态值0.6
         * 刑穿支 动态值0.6  负面值0.6
         */
        // 若宫支存在
        if ($zhi !== '' && !empty($yun))
        {
            // 支出现 动态值1.5
            if ($zhi === $yun[1])
            {
                $gongDongtai += 1.5;
            }
            /**
             * 透干分类
             * 禄干1 该干的禄是该支
             * 唯一干1 在范围内（原局或原局+大运），仅有该干是该支藏干的某五行
             * 唯一正干1 在范围内，仅有该干是该支藏干中的一个
             * 唯一本气干1 在范围内，仅有该干是该支的本气五行
             * 本气正干1 在范围内，仅有该干是该支的本气干
             * 重要性排序：禄干>唯一干>唯一正干>唯一本气干>本气正干，按先后次序寻找它们
             *  如以上几类都没有
             *    有透干
             *      同柱透干优先
             *      无同柱则优先日时干
             *      以上皆无，谁旺谁优先
             *    无透干
             */
//        $tougan = '';
//        if ($zhi)
//        {
//            // 若运干的禄神是宫支
//            if ($shensha['禄神'][$yun[0]] === $zhi)
//            {
//                $tougan = $yun[0];
//            } else
//            {
////                // 天干
////                $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
////                // 地支
////                $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
////                $count = 4;
////                if ($type === 2)
////                {
////                    // 若为流年，原局+大运
////                    $tiangan[] = $dayun[0];
////                    $dizhi[] = $dayun[1];
////                    $count = 5;
////                }
////                $x1Num = $x2Num = $x3Num = $x4Num = 0;
////                $x1 = $x2 = $x3 = $x4 = $x5 = $x6 = '';
////                for ($i = 0; $i < $count; $i++)
////                {
////                    // 遍历该支的藏干
////                    foreach ($canggan[$zhi] as $k1 => $v1)
////                    {
////                        // 唯一干1 在范围内（原局或原局+大运），仅有该干是该支藏干的某五行
////                        if ($this->wx[$tiangan[$i]] === $this->wx[$v1])
////                        {
////                            $x1Num++;
////                            $x1 = $tiangan[$i];
////                        }
////                        // 唯一正干1 在范围内，仅有该干是该支藏干中的一个
////                        if ($tiangan[$i] === $v1)
////                        {
////                            $x2Num++;
////                            $x2 = $tiangan[$i];
////                        }
////                        // 唯一本气干1 在范围内，仅有该干是该支的本气五行
////                        if ($k1 === 0 && $this->wx[$tiangan[$i]] === $this->wx[$v1])
////                        {
////                            $x3Num++;
////                            $x3 = $tiangan[$i];
////                        }
////                        // 本气正干1 在范围内，仅有该干是该支的本气干
////                        if ($k1 === 0 && $tiangan[$i] === $v1)
////                        {
////                            $x4Num++;
////                            $x4 = $tiangan[$i];
////                        }
////                    }
////                }
////                if ($x1Num === 1 && $x1 === $gan)
////                {
////                    $tougan = $x1;
////                } elseif ($x2Num === 1 && $x2 === $gan)
////                {
////                    $tougan = $x2;
////                } elseif ($x3Num === 1 && $x3 === $gan)
////                {
////                    $tougan = $x3;
////                } elseif ($x4Num === 1 && $x4 === $gan)
////                {
////                    $tougan = $x4;
////                } else
////                {
////                    // 如以上几类都没有
////                    foreach ($tiangan as $k1 => $v1)
////                    {
////                        foreach ($dizhi as $k2 => $v2)
////                        {
////                            foreach ($canggan[$v2] as $k3 => $v3)
////                            {
////                                if ($v1 === $v3)
////                                {
////                                    // 同柱透干优先
////                                    if ($k1 === $k2)
////                                    {
////                                        $tougan = $v1;
////                                        break;
////                                    }
////                                    // 无同柱则优先日时干
////                                    if ($k1 === 2)
////                                    {
////                                        $x5 = $v1;
////                                    } elseif ($k1 === 3)
////                                    {
////                                        $x6 = $v1;
////                                    }
////                                }
////
////                            }
////                        }
////                    }
////                    if ($tougan === '')
////                    {
////                        if ($x5 !== '')
////                        {
////                            $tougan = $x5;
////                        } elseif ($x6 !== '')
////                        {
////                            $tougan = $x6;
////                        }
////                    }
////                }
//            }
//        }
            // 透干出现（干禄是该支）
            if ($shensha['禄神'][$yun[0]] === $zhi)
            {
                $gongDongtai += 1.5;
            }
            $isTouGanShouHe = false;
            $isTouGanShouZhengKe = false;
            foreach ($tiangan as $k1 => $v1)
            {
                // 透干受合 (透干受流年/大运合)
                // 透干受合：（大运干受原局合 或 流年干受（原局+大运）合   ） 且 大运/流年干的禄神是宫支 或 大运/流年干的五合的天干的禄神是宫支
                if (($shensha['禄神'][$yun[0]] === $zhi || $shensha['禄神'][$v1] === $zhi)
                    && $this->horoscopeInstance->is_wuhe($v1, $yun[0]))
                {
                    if ($isTouGanShouHe)
                    {
                        $gongDongtai += 1 / 3;
                    } else
                    {
                        $gongDongtai++;
                    }
                    $isTouGanShouHe = true;
                }
                // 透干受正克 (透干受流年/大运同性克)
                // 透干受正克：原局有（宫支透干），受大运干正克，或（原局+大运）有（宫支透干），受流年干正克
                if ($shensha['禄神'][$v1] === $zhi && $this->yy[$v1] === $this->yy[$yun[0]] && in_array($v1, $this->ke[$yun[0]], true))
                {
                    if ($isTouGanShouZhengKe)
                    {
                        $gongFumian += 1 / 3;
                    } else
                    {
                        $gongFumian++;
                    }
                    $isTouGanShouZhengKe = true;
                }
            }
            // 合支
            if ($this->horoscopeInstance->is_liuhe($zhi, $yun[1])
                || $this->horoscopeInstance->is_anhe($zhi, $yun[1]))
            {
                $gongDongtai++;
            }
            // 冲支
            if ($this->horoscopeInstance->is_liuchong($zhi, $yun[1]))
            {
                $gongDongtai++;
                $gongFumian++;
            }
            // 拱支
            if ($this->horoscopeInstance->is_gong($zhi, $yun[1]))
            {
                $gongDongtai += 0.6;
            }
            // 刑穿支
            if ($this->horoscopeInstance->is_xing($zhi, $yun[1]) || $this->horoscopeInstance->is_liuhai($zhi, $yun[1]))
            {
                $gongDongtai += 0.6;
                $gongFumian += 0.6;
            }
        }

        /**
         * 星神
         * 星现一（干或支本气） 动态值1.5
         * 星现二（支藏气且支为辰戌丑未） 动态值0.6
         * 干合原局星 动态值1
         * 干克原局星 负面值1
         * 支合原局星 动态值1
         * 支冲原局星 动态值1 负面值1
         * 支拱原局星 动态值0.6
         * 支刑穿破原局星 动态值0.6 负面值0.6
         * 墓用 动态值1
         */
        $xingDongtai = 0;
        $xingFumian = 0;
        $rigan = $this->bazi['bazi'][5];
        // 星现一（干或支本气） TODO [ 2023-11-14T16:52:47+08:00 ][ error ] 年运分析 报告【一生起伏｜人生阶段｜年运筛查】计算异常 jobData：{"id":"13456"} error:Undefined offset: 0 file:/mnt/zhunle/zhunle_api/apps/common/lib/horoscope/HoroscopeFortune.php:1788
        if (in_array($shishen[$yun[0]][$rigan], $xing, true) || in_array($shishen[$canggan[$yun[1]][0]][$rigan], $xing, true))
        {
            $xingDongtai += 1.5;
        }
        // 星现二（支藏气且支为辰戌丑未）
        if (in_array($yun[1], ['辰', '戌', '丑', '未'], true)
            && (in_array($shishen[$canggan[$yun[1]][1]][$rigan], $xing, true)
                || in_array($shishen[$canggan[$yun[1]][2]][$rigan], $xing, true)))
        {
            $xingDongtai += 0.6;
        }
        $c1 = $c2 = $c3 = $c4 = $c5 = $c6 = false;
        foreach ($this->bazi['bazi'] as $k1 => $v1)
        {
            if ($k1 === 5) continue;
            // 天干
            if ($k1 % 2 === 1)
            {
                $g = $v1;
            } else
            {
                $g = $canggan[$v1][0];
            }
            // 原局星
            if (in_array($shishen[$g][$this->bazi['bazi'][5]], $xing, true))
            {
                // 干合原局星
                if ($c1 === false && $this->horoscopeInstance->is_wuhe($yun[0], $g))
                {
                    $c1 = true;
                    $xingDongtai++;
                }
                // 干克原局星
                if ($c2 === false && $this->ke[$yun[0]] === $g)
                {
                    $c2 = true;
                    $xingFumian++;
                }
                // 支合原局星
                if ($c3 === false && ($this->horoscopeInstance->is_liuhe($yun[0], $v1) || $this->horoscopeInstance->is_anhe($yun[0], $v1)))
                {
                    $c3 = true;
                    $xingDongtai++;
                } // 支冲原局星
                elseif ($this->horoscopeInstance->is_liuchong($yun[0], $v1))
                {
                    $c4 = true;
                    $xingDongtai++;
                    $xingFumian++;
                } // 支拱原局星
                elseif ($this->horoscopeInstance->is_gong($yun[0], $v1))
                {
                    $c5 = true;
                    $xingDongtai += 0.6;
                } // 支刑穿原局星
                elseif ($this->horoscopeInstance->is_xing($yun[0], $v1) || $this->horoscopeInstance->is_liuhai($yun[0], $v1))
                {
                    $c6 = true;
                    $xingDongtai += 0.6;
                    $xingFumian += 0.6;
                }
            }
        }
        // 墓用 原局中墓与被墓支，动态值1
        // 寅未，申丑，亥辰，巳戌，每组两支同时出现，星神之一是组合地支之一的本气
        if (((in_array('寅', $dizhi, true) && $yun[1] === '未') || (in_array('未', $dizhi, true) && $yun[1] === '寅'))
            && (in_array($this->horoscopeInstance->param['shishen'][$canggan['寅'][0]][$tiangan[2]], $xing, true)
                || in_array($this->horoscopeInstance->param['shishen'][$canggan['未'][0]][$tiangan[2]], $xing, true)))
        {
            $xingDongtai++;
        } elseif (((in_array('申', $dizhi, true) && $yun[1] === '丑') || (in_array('丑', $dizhi, true) && $yun[1] === '申'))
            && (in_array($this->horoscopeInstance->param['shishen'][$canggan['申'][0]][$tiangan[2]], $xing, true)
                || in_array($this->horoscopeInstance->param['shishen'][$canggan['丑'][0]][$tiangan[2]], $xing, true)))
        {
            $xingDongtai++;
        } elseif (((in_array('亥', $dizhi, true) && $yun[1] === '辰') || (in_array('辰', $dizhi, true) && $yun[1] === '亥'))
            && (in_array($this->horoscopeInstance->param['shishen'][$canggan['亥'][0]][$tiangan[2]], $xing, true)
                || in_array($this->horoscopeInstance->param['shishen'][$canggan['辰'][0]][$tiangan[2]], $xing, true)))
        {
            $xingDongtai++;
        } elseif (((in_array('巳', $dizhi, true) && $yun[1] === '戌') || (in_array('戌', $dizhi, true) && $yun[1] === '巳'))
            && (in_array($this->horoscopeInstance->param['shishen'][$canggan['巳'][0]][$tiangan[2]], $xing, true)
                || in_array($this->horoscopeInstance->param['shishen'][$canggan['戌'][0]][$tiangan[2]], $xing, true)))
        {
            $xingDongtai++;
        }
        // 如果 关闭流年取用大运分数
//        if ($type === 2)
//        {
//            $data = $this->zhuti($gan, $zhi, $xing, $dayun, $liunian, 1);
//            $dongtai += $data['dongtai'] * 0.5;
//            $fumian += $data['fumian'] * 0.5;
//        }
        return ['gong_dongtai' => $gongDongtai, 'gong_fumian' => $gongFumian, 'xing_dongtai' => $xingDongtai, 'xing_fumian' => $xingFumian];
    }

    /**
     * 获取地址关系
     * @param $zhi1
     * @param $zhi2
     * @return string
     */
    protected function getDizhiReleation($zhi1, $zhi2)
    {
        $res = '其他';
        if ($this->horoscopeInstance->is_liuhe($zhi1, $zhi2))
        {
            $res = '合';
        } elseif ($this->horoscopeInstance->is_liuchong($zhi1, $zhi2))
        {
            $res = '冲';
        } elseif ($this->horoscopeInstance->is_gong($zhi1, $zhi2))
        {
            $res = '拱';
        } elseif ($this->horoscopeInstance->is_xing($zhi1, $zhi2))
        {
            $res = '刑';
        } elseif ($this->horoscopeInstance->is_liuhai($zhi1, $zhi2))
        {
            $res = '穿';
        }
        return $res;
    }

    public function mouMouZhiYun()
    {
        // 流年通过advance参数进行处理

    }

    /**
     * 用神计算
     */
    protected function yongShen($recalculation = false)
    {
        // 仅限于原局计算，得出各干支用神分数，用以观察大运流年是否临用神
        // 初始化十天干十二地支的用神分值为0
        $res = [
            '甲' => 0,
            '乙' => 0,
            '丙' => 0,
            '丁' => 0,
            '戊' => 0,
            '己' => 0,
            '庚' => 0,
            '辛' => 0,
            '壬' => 0,
            '癸' => 0,
            '子' => 0,
            '丑' => 0,
            '寅' => 0,
            '卯' => 0,
            '辰' => 0,
            '巳' => 0,
            '午' => 0,
            '未' => 0,
            '申' => 0,
            '酉' => 0,
            '戌' => 0,
            '亥' => 0
        ];
        /**
         * 一气局：某五行强极
         *  泄该五行为第一用神，克为第二用神，该五行所克为第三用神
         *    用神分10、8、6
         *  该五行所克的吉神到来会有危险
         * 独旺局：某五行独旺（旺度超其它一定比例）
         *  克该五行的五行为第一用神，泄该五行的为第二用神，该五行所克为第三用神
         *    用神分10、8、6
         *  该五行所克的吉神到来如不能入局会有危险
         * 双旺局：两个五行旺度相仿，且超其它一定比例
         *  相生
         *    克受生五行的为第一用神，泄受生五行为第二用神，受生五行所克为第三用神
         *      10、8、6
         *  相克
         *    通关两五行为第一用神，受克五行所生为第二用神，受克五行的比劫为第三用神
         *      10、8、6
         * 身弱局（日主有根气，气力弱）
         *  正印9，比劫8
         *  偏印6
         * 身旺局（日主气力大于15）
         *  正官9，正偏财8，七杀5，食神7，伤官5
         */
        $data = [];
        if ($recalculation || empty($this->bazi) || $this->horoscopeInstance === null)
        {
            $this->horoscopeInstance = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $this->advance]);
            $this->bazi = $this->horoscopeInstance->getUserData();
        }
//        $data['bazi'] = implode('', $this->bazi['bazi']);
//        $data['dayun'] = implode('', $this->horoscopeInstance->data['dayun_now']);
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        // 地支藏干表
        $canggan = $this->horoscopeInstance->param['canggan'];
        $rigan = $tiangan[2];
        $data['power'] = $this->tianganPower();
        $data['health'] = $this->jiankangPower();

        $data['wx'] = [
            '金' => 0,
            '水' => 0,
            '木' => 0,
            '火' => 0,
            '土' => 0,
        ];
        // 计算五行旺衰
        foreach ($this->wxg as $k1 => $v1)
        {
            // $k1=五行 $v1=属于该五行的两个天干
            /**
             * 计算五行旺衰
             *  弱战 1
             *    某五行有且仅有唯一根为本气根，该根不在月令，该根受敌对根（克自己的五行根，包括本气，库藏气）冲穿
             *  强战 2
             *    某五行为月令本气或气力值【15】以上，根气之一受敌对根冲穿
             *  强缚 3
             *    某五行为月令本气（非土），且月令为唯一根，不受相邻地支本气之生，相邻两支皆为其敌对根，时支与之相合、相拱或暗合，天干不透
             *  强和 4
             *    某五行气力值15以上，地支根气不受刑冲穿，如透干不受正克
             *  强极 5
             *    气力值28以上
             */
            // 计算该五行气力值
            $power = $data['power'][$v1[0]]['score'] + $data['power'][$v1[1]]['score'];
            $wxBenqiGenNum = 0;
            $wxGenNum = 0;
            $wxGanNum = 0;
            $genqiShouXingChongChuan = false;
            $x1_1 = $x2_1 = $x3_1 = $x3_2 = $x3_3 = $x3_4 = $x3_5 = $x4_1 = $x4_2 = false;

            foreach ($tiangan as $k2 => $v2)
            {
                if (in_array($v2, $v1, true))
                {
                    $wxGanNum++;
                    foreach ($tiangan as $k3 => $v3)
                    {
                        if ($k2 < $k3 && $this->yy[$v2] === $this->yy[$v3] && in_array($v3, $this->beiKe[$v2], true))
                        {
                            $x4_2 = true;
                        }
                    }
                }
            }
            if ($wxGanNum === 0)
            {
                $x3_5 = true;
            }

            foreach ($dizhi as $k2 => $v2)
            {
                // 检测是否被敌对根刑冲穿
                $isBeiDiduiXingChongChuan = false;
                $next = $k2 + 1;
                $prev = $k2 - 1;
                // 年时在边上，只有一个邻支，不受相邻地支本气之生
                if ($next <= 3 && $this->wxSheng[$this->wx[$canggan[$dizhi[$next]][0]]] !== $k1
                    && $prev >= 0 && $this->wxSheng[$this->wx[$canggan[$dizhi[$prev]][0]]] !== $k1)
                {
                    $x3_2 = true;
                }
                $isXianglingDidui1 = false;
                $isXianglingDidui2 = false;
                foreach ($dizhi as $k3 => $v3)
                {
                    if ($k2 !== $k3)
                    {
                        // 开始检查是否为敌对根
                        $isDidui = false;
                        foreach ($canggan[$v3] as $k4 => $v4)
                        {
                            if (in_array($this->wx[$v4], $this->wxg[$this->wxBeiKe[$k1]], true))
                            {
                                $isDidui = true;
                                break;
                            }
                        }
                        // 被刑冲穿
                        if ($this->horoscopeInstance->is_liuchong($v2, $v3)
                            || $this->horoscopeInstance->is_liuhai($v2, $v3)
                            || $this->horoscopeInstance->is_xing($v2, $v3))
                        {
                            $genqiShouXingChongChuan++;
                            // 敌对根
                            if ($isDidui)
                            {
                                $isBeiDiduiXingChongChuan = true;
                            }
                        }
                        if ($next > 3 || $next === $k3)
                        {
                            $isXianglingDidui1 = true;
                        }
                        if ($prev < 0 || $prev === $k3)
                        {
                            $isXianglingDidui2 = true;
                        }
                    }
                }
                // 相邻两支皆为其敌对根
                if ($isXianglingDidui1 && $isXianglingDidui2)
                {
                    $x3_3 = true;
                }
                foreach ($canggan[$v2] as $k3 => $v3)
                {
                    if ($this->wx[$v3] === $k1)
                    {
                        $wxGenNum++;
                    }
                }
                // 本气五行为该五行
                if (in_array($canggan[$v2][0], $v1, true))
                {
                    $wxBenqiGenNum++;
                    // 该根不在月令
                    if ($k2 !== 1)
                    {
                        if ($isBeiDiduiXingChongChuan)
                        {
                            $x1_1 = true;
                        }
                    }
                    if ($k2 === 1 || $power > 15)
                    {
                        if ($isBeiDiduiXingChongChuan)
                        {
                            $x2_1 = true;
                        }
                    }
                    // 月令本气非土
                    if ($k2 === 1 && $k1 !== '土')
                    {
                        $x3_1 = true;
                        // 时支与之相合、相拱或暗合
                        if ($this->horoscopeInstance->is_liuhe($v2, $dizhi[3])
                            || $this->horoscopeInstance->is_gong($v2, $dizhi[3])
                            || $this->horoscopeInstance->is_anhe($v2, $dizhi[3]))
                        {
                            $x3_4 = true;
                        }
                    }
                }
            }
            if ($genqiShouXingChongChuan === 0)
            {
                $x4_1 = true;
            }
            // 弱战
            if ($wxBenqiGenNum === 1 && $x1_1)
            {
                $data['wx'][$k1] = 1;
            } elseif ($x2_1)
            {
                $data['wx'][$k1] = 2;
            } elseif ($wxGenNum === 1 && $x3_1 && $x3_2 && $x3_3 && $x3_4 && $x3_5)
            {
                $data['wx'][$k1] = 3;
            } elseif ($x4_1 && !$x4_2)
            {
                $data['wx'][$k1] = 4;
            } elseif ($power > 56)
            {
                $data['wx'][$k1] = 5;
            }
        }
        $wxQiangjiNum = 0;
        $wxQiangji = '';
        $wxDuwang = '';
        $wxShuangwang = [];
        $moreThan70 = 0;
        $moreThan45 = 0;
        $lessThan20 = 0;
        /**
         * 一气局：有且仅有一个五行强极
         * 独旺，五行其中一干，综合实力值大于70
         * 双旺，两个五行各有一干综合实力值大于45，且其它三种五行，各干综合实力都小于20
         */
        foreach ($data['wx'] as $k1 => $v1)
        {
            $wxg = $this->wxg[$k1];
            // 一气局：某五行强极
            if ($v1 === 5)
            {
                $wxQiangjiNum++;
                $wxQiangji = $k1;
            }
            // 其中有一干综合实力值>70
            if ($data['health'][$wxg[0]]['zong_shili'] > 70 || $data['health'][$wxg[1]]['zong_shili'] > 70)
            {
                $moreThan70++;
                $wxDuwang = $k1;
            }
            // 其中有一干综合实力值>45
            if ($data['health'][$wxg[0]]['zong_shili'] > 45 || $data['health'][$wxg[1]]['zong_shili'] > 45)
            {
                $moreThan45++;
                $wxShuangwang[] = $k1;
            }
            // 两干综合实力值均小于20
            if ($data['health'][$wxg[0]]['zong_shili'] < 20 && $data['health'][$wxg[1]]['zong_shili'] < 20)
            {
                $lessThan20++;
            }
        }
        $yongshen1 = $yongshen2 = $yongshen3 = '';
        if ($moreThan45 === 2 && $lessThan20 === 3)
        {

            // 检查两个五行是相生还是相克
            if ($this->wxKe[$wxShuangwang[0]] === $wxShuangwang[1])
            {
                // 相克 (通关：生受克方的五行)
                //	通关两五行为第一用神，受克五行所生为第二用神，受克五行的比劫为第三用神
                //		10、8、6
                $yongshen1 = $this->wxg[$this->wxBeiSheng[$wxShuangwang[1]]];
                $yongshen2 = $this->wxg[$this->wxSheng[$wxShuangwang[1]]];
                $yongshen3 = $this->wxg[$wxShuangwang[1]];

            } elseif ($this->wxBeiKe[$wxShuangwang[0]] === $wxShuangwang[1])
            {
                // 相克 (通关：生受克方的五行)
                $yongshen1 = $this->wxg[$this->wxBeiSheng[$wxShuangwang[0]]];
                $yongshen2 = $this->wxg[$this->wxSheng[$wxShuangwang[0]]];
                $yongshen3 = $this->wxg[$wxShuangwang[0]];
            } elseif ($this->wxSheng[$wxShuangwang[0]] === $wxShuangwang[1])
            {
                // 相生
                //	克受生五行的为第一用神，泄受生五行为第二用神，受生五行所克为第三用神
                //		10、8、6
                $yongshen1 = $this->wxg[$this->wxKe[$wxShuangwang[1]]];
                $yongshen2 = $this->wxg[$this->wxSheng[$wxShuangwang[1]]];
                $yongshen3 = $this->wxg[$this->wxBeiKe[$wxShuangwang[1]]];
            } elseif ($this->wxBeiSheng[$wxShuangwang[0]] === $wxShuangwang[1])
            {
                $yongshen1 = $this->wxg[$this->wxKe[$wxShuangwang[0]]];
                $yongshen2 = $this->wxg[$this->wxSheng[$wxShuangwang[0]]];
                $yongshen3 = $this->wxg[$this->wxBeiKe[$wxShuangwang[0]]];
            }
        } elseif ($moreThan70 === 1)
        {
            // 克该五行的五行为第一用神，泄该五行的为第二用神，该五行所克为第三用神
            //	用神分10、8、6
            $yongshen1 = $this->wxg[$this->wxBeiKe[$wxDuwang]];
            $yongshen2 = $this->wxg[$this->wxBeiSheng[$wxDuwang]];
            $yongshen3 = $this->wxg[$this->wxKe[$wxDuwang]];
            // 给天干加分、给地支本气加分
            $n = 0;
            foreach ($res as $k2 => $v2)
            {
                // 十天干
                if ($n <= 9)
                {
                    if (in_array($k2, $yongshen1, true))
                    {
                        $res[$k2] += 10;
                    }
                    if (in_array($k2, $yongshen2, true))
                    {
                        $res[$k2] += 8;
                    }
                    if (in_array($k2, $yongshen3, true))
                    {
                        $res[$k2] += 6;
                    }
                } else
                {
                    if (in_array($canggan[$k2][0], $yongshen1, true))
                    {
                        $res[$k2] += 10;
                    }
                    if (in_array($canggan[$k2][0], $yongshen2, true))
                    {
                        $res[$k2] += 8;
                    }
                    if (in_array($canggan[$k2][0], $yongshen3, true))
                    {
                        $res[$k2] += 6;
                    }
                }
                $n++;
            }
        } elseif ($wxQiangjiNum === 1)
        {
            // 泄该五行为第一用神，克为第二用神，该五行所克为第三用神 用神分10、8、6
            $yongshen1 = $this->wxg[$this->wxBeiSheng[$wxQiangji]];
            $yongshen2 = $this->wxg[$this->wxBeiKe[$wxQiangji]];
            $yongshen3 = $this->wxg[$this->wxKe[$wxQiangji]];
        } else
        {
            // 身旺局（日主气力大于15）
            //	正官9，正偏财8，七杀5，食神7，伤官5
            if ($data['power'][$tiangan[2]]['level'] > 2)
            {
                $zhengguan = $this->shishens[$rigan]['正官'];
                $zhengcai = $this->shishens[$rigan]['正财'];
                $piancai = $this->shishens[$rigan]['偏财'];
                $qisha = $this->shishens[$rigan]['七杀'];
                $shishen = $this->shishens[$rigan]['食神'];
                $shangguan = $this->shishens[$rigan]['伤官'];
                $res[$zhengguan] += 9;
                $res[$zhengcai] += 8;
                $res[$piancai] += 8;
                $res[$qisha] += 5;
                $res[$shishen] += 7;
                $res[$shangguan] += 5;
            } else
            {
                // 身弱局（气力弱） 正印9，比劫8 偏印6
                $zhengyin = $this->shishens[$rigan]['正印'];
                $bijian = $this->shishens[$rigan]['比肩'];
                $jiecai = $this->shishens[$rigan]['劫财'];
                $pianyin = $this->shishens[$rigan]['偏印'];
                $res[$zhengyin] += 9;
                $res[$bijian] += 8;
                $res[$jiecai] += 8;
                $res[$pianyin] += 5;
            }
        }
        if ($yongshen1 !== '' && $yongshen2 !== '' && $yongshen3 !== '')
        {
            // 给天干加分、给地支本气加分
            $n = 0;
            foreach ($res as $k2 => $v2)
            {
                // 十天干
                if ($n <= 9)
                {
                    if (in_array($k2, $yongshen1, true))
                    {
                        $res[$k2] += 10;
                    }
                    if (in_array($k2, $yongshen2, true))
                    {
                        $res[$k2] += 8;
                    }
                    if (in_array($k2, $yongshen3, true))
                    {
                        $res[$k2] += 6;
                    }
                } else
                {
                    if (in_array($canggan[$k2][0], $yongshen1, true))
                    {
                        $res[$k2] += 10;
                    }
                    if (in_array($canggan[$k2][0], $yongshen2, true))
                    {
                        $res[$k2] += 8;
                    }
                    if (in_array($canggan[$k2][0], $yongshen3, true))
                    {
                        $res[$k2] += 6;
                    }
                }
                $n++;
            }
        }

        /**
         * 调候 (此处天干对应的本气地支也加分)
         * 亥子丑月见丙（8）丁（6）戊（5）己（3）
         * 巳午未月见壬（8）癸（6）甲（5）乙（3）
         * 寅卯辰月，对比水火旺度，火旺于水则庚（8）辛（6），水旺于火则丙（8）丁（6）戊（5）己3
         * 申酉戌月，对比水火旺度，火旺于水则壬8癸6甲5乙3，水旺于火则丙8丁6
         */
        if (in_array($dizhi[1], ['亥', '子', '丑'], true))
        {
            foreach ($tiangan as $k1 => $v1)
            {
                if ($v1 === '丙')
                {
                    $res[$v1] += 8;
                    $res['巳'] += 8;
                } elseif ($v1 === '丁')
                {
                    $res[$v1] += 6;
                    $res['午'] += 8;
                } elseif ($v1 === '戊')
                {
                    $res[$v1] += 5;
                    $res['辰'] += 5;
                    $res['戌'] += 5;
                } elseif ($v1 === '己')
                {
                    $res[$v1] += 3;
                    $res['丑'] += 3;
                    $res['未'] += 3;
                }
            }
        } elseif (in_array($dizhi[1], ['巳', '午', '未'], true))
        {
            foreach ($tiangan as $k1 => $v1)
            {
                if ($v1 === '壬')
                {
                    $res[$v1] += 8;
                    $res['亥'] += 8;
                } elseif ($v1 === '癸')
                {
                    $res[$v1] += 6;
                    $res['子'] += 6;
                } elseif ($v1 === '甲')
                {
                    $res[$v1] += 5;
                    $res['寅'] += 5;
                } elseif ($v1 === '乙')
                {
                    $res[$v1] += 3;
                    $res['卯'] += 3;
                }
            }
        } elseif (in_array($dizhi[1], ['寅', '卯', '辰'], true))
        {
            $shuiwang = $data['health']['壬']['shili'] + $data['health']['癸']['shili'];
            $huowang = $data['health']['丙']['shili'] + $data['health']['丁']['shili'];
            if ($huowang > $shuiwang)
            {
                $res['庚'] += 8;
                $res['辛'] += 6;

                $res['申'] += 6;
                $res['酉'] += 6;
            } elseif ($huowang < $shuiwang)
            {
                $res['丙'] += 8;
                $res['丁'] += 6;
                $res['戊'] += 5;
                $res['己'] += 3;

                $res['巳'] += 8;
                $res['午'] += 8;
                $res['辰'] += 5;
                $res['戌'] += 5;
                $res['丑'] += 3;
                $res['未'] += 3;
            }
        } elseif (in_array($dizhi[1], ['申', '酉', '戌'], true))
        {
            $shuiwang = $data['health']['壬']['shili'] + $data['health']['癸']['shili'];
            $huowang = $data['health']['丙']['shili'] + $data['health']['丁']['shili'];
            if ($huowang > $shuiwang)
            {
                $res['壬'] += 8;
                $res['癸'] += 6;
                $res['甲'] += 5;
                $res['乙'] += 3;

                $res['亥'] += 8;
                $res['子'] += 6;
                $res['寅'] += 5;
                $res['卯'] += 3;
            } elseif ($huowang < $shuiwang)
            {
                $res['丙'] += 8;
                $res['丁'] += 6;

                $res['巳'] += 8;
                $res['午'] += 6;
            }
        }

        /**
         * 病药
         *  吉神受伤之病
         *    出现偏印克食神、劫财克正财、伤官克正官、正财克正印
         *      天干明见两者，凶神所生之异性6、克凶神之同性10、合凶神之天干10、凶神所生同性3、克凶神异性（非合干）6【只取天干】
         *      地支本气为两者且刑冲穿合，本气克凶神之地支8、合冲凶神之地支（非受害支）7【仅取地支】
         *  凶神过旺之病
         *    七杀、偏印、劫财、伤官旺度超过阈值（？待定）
         *      凶神所生之异性6、克凶神之同性10、合凶神之天干10、凶神所生同性3、克凶神异性（非合干）6
         *    七杀、偏印、劫财、伤官旺度超过第二阈值（过旺？待定）
         *      凶神所生之异性10、克凶神之同性6、合凶神之天干10、凶神所生同性4、克凶神异性（非合干）8
         *      冲凶神本气地支之地支-6，穿凶神本气地支之地支-3（如凶神为劫财，多-4）
         */
        // 天干五合
        $tianganwuhe = [
            '甲' => '己',
            '乙' => '庚',
            '丙' => '辛',
            '丁' => '壬',
            '戊' => '癸',
            '己' => '甲',
            '庚' => '乙',
            '辛' => '丙',
            '壬' => '丁',
            '癸' => '戊',
        ];
        // 正财 财 我克者，同性为偏财，异性为正财
        // 偏财 才
        // 正印 印 生我者，同性为偏印，异性为正印
        // 偏印 枭
        // 食神 食 我生者，同性为食神，异性为伤官
        // 伤官 伤
        // 比肩 比 同我者，同性为比肩，异性为劫财
        // 劫财 劫
        // 七杀 杀 克我者，同性为七杀，异性为正官
        // 正官 官
        // 天干明见两者 出现偏印克食神、劫财克正财、伤官克正官、正财克正印
        $xiongshen1 = $jishen1 = [];
        if (in_array('枭', $this->bazi['shishen1'], true) && in_array('食', $this->bazi['shishen1'], true))
        {
            $xiongshen1[] = $tiangan[array_search('枭', $this->bazi['shishen1'], true)];
            $jishen1[] = $tiangan[array_search('食', $this->bazi['shishen1'], true)];
        }
        if (in_array('劫', $this->bazi['shishen1'], true) && in_array('财', $this->bazi['shishen1'], true))
        {
            $xiongshen1[] = $tiangan[array_search('劫', $this->bazi['shishen1'], true)];
            $jishen1[] = $tiangan[array_search('财', $this->bazi['shishen1'], true)];
        }
        if (in_array('伤', $this->bazi['shishen1'], true) && in_array('官', $this->bazi['shishen1'], true))
        {
            $xiongshen1[] = $tiangan[array_search('伤', $this->bazi['shishen1'], true)];
            $jishen1[] = $tiangan[array_search('官', $this->bazi['shishen1'], true)];
        }
        if (in_array('财', $this->bazi['shishen1'], true) && in_array('印', $this->bazi['shishen1'], true))
        {
            $xiongshen1[] = $tiangan[array_search('财', $this->bazi['shishen1'], true)];
            $jishen1[] = $tiangan[array_search('印', $this->bazi['shishen1'], true)];
        }
        if (!empty($xiongshen1))
        {
            foreach ($xiongshen1 as $k1 => $v1)
            {
                // 凶神所生之异性6、克凶神之同性10、合凶神之天干10、凶神所生同性3、克凶神异性（非合干）6
                $xyyt = $this->yy[$v1];
                $xyyy = $xyyt ? 1 : 0;
                $res[$this->sheng[$v1][$xyyy]] += 6;
                $res[$this->beiKe[$v1][$xyyt]] += 10;
                $res[$tianganwuhe[$v1]] += 10;
                $res[$this->sheng[$v1][$xyyt]] += 3;
                if ($tianganwuhe[$v1] !== $this->beiKe[$v1][$xyyy])
                {
                    $res[$this->beiKe[$v1][$xyyy]] += 6;
                }
            }
        }
        $xiongshen2 = $jishen2 = [];
        $dizhiShishen = [];
        foreach ($this->bazi['shishen2'] as $k1 => $v1)
        {
            $dizhiShishen[] = mb_substr($v1, 0, 1);
        }
        if (in_array('枭', $dizhiShishen, true) && in_array('食', $dizhiShishen, true))
        {
            $xiongshen2[] = $dizhi[array_search('枭', $dizhiShishen, true)];
            $jishen2[] = $dizhi[array_search('食', $dizhiShishen, true)];
        }
        if (in_array('劫', $dizhiShishen, true) && in_array('财', $dizhiShishen, true))
        {
            $xiongshen2[] = $dizhi[array_search('劫', $dizhiShishen, true)];
            $jishen2[] = $dizhi[array_search('财', $dizhiShishen, true)];
        }
        if (in_array('伤', $dizhiShishen, true) && in_array('官', $dizhiShishen, true))
        {
            $xiongshen2[] = $dizhi[array_search('伤', $dizhiShishen, true)];
            $jishen2[] = $dizhi[array_search('官', $dizhiShishen, true)];
        }
        if (in_array('财', $dizhiShishen, true) && in_array('印', $dizhiShishen, true))
        {
            $xiongshen2[] = $dizhi[array_search('财', $dizhiShishen, true)];
            $jishen2[] = $dizhi[array_search('印', $dizhiShishen, true)];
        }
        if (!empty($xiongshen2))
        {
            foreach ($xiongshen2 as $k1 => $v1)
            {
                // 地支本气为两者且刑冲穿合，本气克凶神之地支8、合冲凶神之地支（非受害支）7【仅取地支】
                if ($this->horoscopeInstance->is_xing($v1, $jishen2[$k1])
                    || $this->horoscopeInstance->is_liuchong($v1, $jishen2[$k1])
                    || $this->horoscopeInstance->is_liuhai($v1, $jishen2[$k1])
                    || $this->horoscopeInstance->is_liuhe($v1, $jishen2[$k1])
                    || $this->horoscopeInstance->is_anhe($v1, $jishen2[$k1]))
                {
                    $xscg = $canggan[$v1][0];
                    // 遍历12地支
                    foreach ($this->horoscopeInstance->param['earthly_branches'] as $k2 => $v2)
                    {
                        $dzcg = $canggan[$v2][0];
                        // 本气克凶神之地支8
                        if (in_array($xscg, $this->ke[$dzcg], true))
                        {
                            $res[$v2] += 8;
                        }
                        if ($v2 !== $jishen2[$k1] && ($this->horoscopeInstance->is_liuhe($v1, $v2)
                                || $this->horoscopeInstance->is_anhe($v1, $v2)
                                || $this->horoscopeInstance->is_liuchong($v1, $v2)))
                        {
                            $res[$v2] += 7;
                        }
                    }
//                    foreach ($dizhi as $k2 => $v2)
//                    {
//                        $dzcg = $canggan[$v2][0];
//                        // 本气克凶神之地支8
//                        if (in_array($xscg, $this->ke[$dzcg], true))
//                        {
//                            $res[$v2] += 8;
//                        }
//                        if ($v2 !== $jishen2[$k1] && ($this->horoscopeInstance->is_liuhe($v1, $v2)
//                                || $this->horoscopeInstance->is_anhe($v1, $v2)
//                                || $this->horoscopeInstance->is_liuchong($v1, $v2)))
//                        {
//                            $res[$v2] += 7;
//                        }
//                    }
                }
            }
        }

        /**
         *  凶神过旺之病
         *    七杀、偏印、劫财、伤官旺度超过阈值 气力值15 level=2
         *      凶神所生之异性6、克凶神之同性10、合凶神之天干10、凶神所生同性3、克凶神异性（非合干）6
         *    七杀、偏印、劫财、伤官旺度超过第二阈值 气力值21 level=4
         *      凶神所生之异性10、克凶神之同性6、合凶神之天干10、凶神所生同性4、克凶神异性（非合干）8
         *      冲凶神本气地支之地支-6，穿凶神本气地支之地支-3（如凶神为劫财，多-4）
         */
        $xiongshen3 = [
            $this->shishens[$rigan]['七杀'],
            $this->shishens[$rigan]['偏印'],
            $this->shishens[$rigan]['劫财'],
            $this->shishens[$rigan]['伤官'],
        ];
        foreach ($xiongshen3 as $k1 => $v1)
        {
//            if ($data['power'][$v1]['level'] >= 2)
//            {
//                // 凶神所生之异性6、克凶神之同性10、合凶神之天干10、凶神所生同性3、克凶神异性（非合干）6
//                $xyyt = $this->yy[$v1];
//                $xyyy = $xyyt ? 1 : 0;
//                $res[$this->sheng[$v1][$xyyy]] += 6;
//                $res[$this->beiKe[$v1][$xyyt]] += 10;
//                $res[$tianganwuhe[$v1]] += 10;
//                $res[$this->sheng[$v1][$xyyt]] += 3;
//                if ($tianganwuhe[$v1] !== $this->beiKe[$v1][$xyyy])
//                {
//                    $res[$this->beiKe[$v1][$xyyy]] += 6;
//                }
//            } else
            if ($data['power'][$v1]['level'] >= 4)
            {
                // 凶神所生之异性10、克凶神之同性6、合凶神之天干10、凶神所生同性4、克凶神异性（非合干）8
                $xyyt = $this->yy[$v1];
                $xyyy = $xyyt ? 1 : 0;
                $res[$this->sheng[$v1][$xyyy]] += 10;
                $res[$this->beiKe[$v1][$xyyt]] += 6;
                $res[$tianganwuhe[$v1]] += 10;
                $res[$this->sheng[$v1][$xyyt]] += 4;
                if ($tianganwuhe[$v1] !== $this->beiKe[$v1][$xyyy])
                {
                    $res[$this->beiKe[$v1][$xyyy]] += 8;
                }
                // 冲凶神本气地支之地支-6，穿凶神本气地支之地支-3（如凶神为劫财，多-4）
                foreach ($this->horoscopeInstance->param['earthly_branches'] as $k2 => $v2)
                {
                    // 地支本气藏干为凶神
                    if ($canggan[$v2][0] === $v1)
                    {
                        foreach ($this->horoscopeInstance->param['earthly_branches'] as $k3 => $v3)
                        {
                            if ($k2 !== $v3)
                            {
                                if ($this->horoscopeInstance->is_liuchong($v2, $v3))
                                {
                                    $res[$v3] += 6;
                                }
                                if ($this->horoscopeInstance->is_liuhai($v2, $v3))
                                {
                                    $res[$v3] -= 3;
                                    if ($this->horoscopeInstance->param['shishen'][$v1][$rigan] === '劫财')
                                    {
                                        $res[$v3] -= 4;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return $res;
    }

    /**
     * 动应计算
     * @param string $xing 正官/七杀 等
     * @param int $type 0=>本命,1=>大运,2=>流年
     * @param array $dayun
     * @param array $liunian
     * @return float
     */
    protected function dongyingScore($xing = '', $type = 0, $dayun = [], $liunian = [])
    {
        $res = 0;
        if (empty($dayun))
        {
            return $res;
        }
        /**
         * 动应系数
         * 某干神的动应系数，以岁运的动态来计算，基础值为零，在此基础上加
         * 出现 干1 支 取其根气值/10
         * 干合 0.8
         * 支合 被合支中根气值*0.8/10
         * 支拱 被拱支中根气值*0.6/10
         * 支冲 被冲支中根气值*0.8/10
         * 支刑穿 被刑穿支中根气值*0.5/10
         * 墓用 原局中墓与被墓支，其本气根气值*0.8/10
         * 禄通透 此为特殊形式的“出现”，额外计+0.2
         * 各值相加 是否需特殊处理待观察
         */
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        if ($type === 2)
        {
            $yun = $liunian;
            $tiangan[] = $dayun[0];
            $dizhi[] = $dayun[1];
        } else
        {
            $yun = $dayun;
        }
        // 地支藏干表
        $canggan = $this->horoscopeInstance->param['canggan'];
        $xingGan = $this->shishens[$tiangan[2]][$xing];
        // 干出现  运势天干出现该十神
        if ($yun[0] === $xingGan)
        {
            $res++;
        }
        $ganHeNum = 0;
        // 遍历天干
        foreach ($tiangan as $k1 => $v1)
        {
            // 干合
            if ($this->horoscopeInstance->is_wuhe($v1, $yun[0])
                && ($yun[0] === $xingGan || $v1 === $xingGan))
            {
                $ganHeNum++;
                $x = $ganHeNum > 1 ? 0.4 : 0.8;
                $res += $x;
            }
        }
        $isYunZhiYouXingGan = false;
        foreach ($canggan[$yun[1]] as $k1 => $v1)
        {
            if ($v1 === $xingGan)
            {
                $isYunZhiYouXingGan = true;
                $res += $this->genqi[$yun[1]][$v1] / 10;
                break;
            }
        }
        // 遍历地支
        foreach ($dizhi as $k1 => $v1)
        {
            $v1Genqi = 0;
            $isDizhiYouXingGan = false;
            // 遍历地支藏干
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                if ($v2 === $xingGan)
                {
                    $isDizhiYouXingGan = true;
                }
            }
            //  || $isYunZhiYouXingGan
            // 若原局地支藏干中有传入的食神天干，判断地支与运支的关系
            if ($isDizhiYouXingGan)
            {
                $v1Genqi = $this->genqi[$v1][$xingGan];
                if ($this->horoscopeInstance->is_liuhe($yun[1], $v1) || $this->horoscopeInstance->is_anhe($yun[1], $v1))
                {
                    $res += $v1Genqi * 0.8 / 10;
                } elseif ($this->horoscopeInstance->is_gong($yun[1], $v1))
                {
                    $res += $v1Genqi * 0.6 / 10;
                } elseif ($this->horoscopeInstance->is_liuchong($yun[1], $v1))
                {
                    $res += $v1Genqi * 0.8 / 10;
                } elseif ($this->horoscopeInstance->is_xing($yun[1], $v1) || $this->horoscopeInstance->is_liuhai($yun[1], $v1))
                {
                    $res += $v1Genqi * 0.5 / 10;
                }
            }
        }
        // 禄通透，就是原局有某个干的禄，（大运/流年）再出现这个干 或者原局有某个干，大运出现它的禄
        $lushen = $this->horoscopeInstance->param['shensha']['禄神'];
        foreach ($tiangan as $k1 => $v1)
        {
            if ($lushen[$v1] === $yun[0] || $lushen[$yun[0]] === $v1)
            {
                $res += 0.2;
            }
        }
        // 墓用 原局中墓与被墓支，其本气根气值*0.8/10 (墓与被墓必须一个是运支一个是原局支，本气为该十神的计算分值)
        // 寅未，申丑，亥辰，巳戌，每组两支同时出现
        $muNum = 0;
        if (('未' === $yun[1] && in_array('寅', $dizhi, true)) || ('寅' === $yun[1] && in_array('未', $dizhi, true)))
        {
            if ($canggan['寅'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['寅'][$xingGan] * 0.8 / 10;
            } elseif ($canggan['未'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['未'][$xingGan] * 0.8 / 10;
            }
        }
        if ($muNum === 0 && (('申' === $yun[1] && in_array('丑', $dizhi, true)) || ('丑' === $yun[1] && in_array('申', $dizhi, true))))
        {
            if ($canggan['申'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['申'][$xingGan] * 0.8 / 10;
            } elseif ($canggan['丑'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['丑'][$xingGan] * 0.8 / 10;
            }
        }
        if ($muNum === 0 && (('亥' === $yun[1] && in_array('辰', $dizhi, true)) || ('辰' === $yun[1] && in_array('亥', $dizhi, true))))
        {
            if ($canggan['亥'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['亥'][$xingGan] * 0.8 / 10;
            } elseif ($canggan['辰'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['辰'][$xingGan] * 0.8 / 10;
            }
        }
        if ($muNum === 0 && (('巳' === $yun[1] && in_array('戌', $dizhi, true)) || ('戌' === $yun[1] && in_array('巳', $dizhi, true))))
        {
            if ($canggan['巳'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['巳'][$xingGan] * 0.8 / 10;
            } elseif ($canggan['戌'][0] === $xingGan)
            {
                $muNum++;
                $res += $this->genqi['戌'][$xingGan] * 0.8 / 10;
            }
        }

        return $res;
    }

    /**
     * 计算亲和系数
     * @param int $type 0=>本命,1=>大运,2=>流年
     * @param array $dayun
     * @param array $liunian
     * @return float
     */
    public function qinheScore($type = 0, $dayun = [], $liunian = [])
    {
        $res = 1;
        /**
         * 亲和系数
         * 基数为1，大运与原局、或流年与局运刑冲穿者降低，合拱者提升
         * 干合
         *  日干1.5，时干1.35，月干1.25，年干1.15 运干1.35
         * 干克（只取同性）
         *  1-（1-1/合系数）*0.8
         * 支合（包括暗合，卯申、午亥、巳酉）
         *  日支1.5，时支1.35，月支1.2，年支1.15 运支 1.35（仅计算流年时生效）
         * 支拱
         *  1+（合系数-1）*0.7
         * 支冲
         *  1/合系数
         * 支穿（害）
         *  1-（1-1/合系数）*0.8
         * 支刑
         *  1-（1-1/合系数）*0.8
         * 复合关系（两种及以上），如都是负面关系，取低系数，如都是正面关系，取高系数，如正负都有，取两次【即，对每组干支，取正面系数最高者，同时取负面系数最低者，无则不取】
         * 计算大运时，大运支-原局系数整合，计算流年时，流年支-局运系数整合（相乘）
         * 如与日支相合，最终系数不得低于1.2，低于1.2取1.2
         * 如与日支相冲，最终系数不得高于0.9，高于0.9取0.9
         */
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        if ($type === 2)
        {
            $yun = $liunian;
            $tiangan[] = $dayun[0];
            $dizhi[] = $dayun[1];
        } else
        {
            $yun = $dayun;
        }
        $ganHeX = [1.15, 1.25, 1.5, 1.35, 1.35];
        $zhiHeX = [1.15, 1.2, 1.5, 1.35, 1.35];
        $zhengmianNum = 0;
        $fumianNum = 0;
        foreach ($tiangan as $k1 => $v1)
        {
            if ($this->horoscopeInstance->is_wuhe($yun[0], $v1))
            {
                $res *= $ganHeX[$k1];
            }
            if ($this->yy[$v1] === $this->yy[$yun[0]] && ($this->ke[$yun[0]] === $v1 || $this->ke[$v1] === $yun[0]))
            {
                $res *= (1 - (1 - 1 / $ganHeX[$k1]) * 0.8);
            }
        }
        // 如果冲日支，那么拱合（不包括暗合）原局得分均取倒数；如果穿日支，那么合（不包括暗合）原局得分取倒数
        $isChongRizhi = $this->horoscopeInstance->is_liuchong($yun[1], $dizhi[2]);
        $isChuanRizhi = $this->horoscopeInstance->is_liuhai($yun[1], $dizhi[2]);
        foreach ($dizhi as $k1 => $v1)
        {
            if ($this->horoscopeInstance->is_liuhe($v1, $yun[1]))
            {
                if ($isChongRizhi || $isChuanRizhi)
                {
                    $res *= 1 / $zhiHeX[$k1];
                } else
                {
                    $res *= $zhiHeX[$k1];
                }
            } elseif ($this->horoscopeInstance->is_anhe($v1, $yun[1]))
            {
                $res *= $zhiHeX[$k1];
            } elseif ($this->horoscopeInstance->is_gong($v1, $yun[1]))
            {
                if ($isChongRizhi)
                {
                    $res *= 1 / (1 + ($zhiHeX[$k1] - 1) * 0.7);
                } else
                {
                    $res *= (1 + ($zhiHeX[$k1] - 1) * 0.7);
                }
            }
            if ($this->horoscopeInstance->is_liuchong($v1, $yun[1]))
            {
                $res *= (1 / $zhiHeX[$k1]);
            } elseif ($this->horoscopeInstance->is_liuhai($v1, $yun[1]))
            {
                $res *= (1 - (1 - 1 / $zhiHeX[$k1]) * 0.8);
            } elseif ($this->horoscopeInstance->is_xing($v1, $yun[1]))
            {
                $res *= (1 - (1 - 1 / $zhiHeX[$k1]) * 0.8);
            }
        }
//        /**
//         * 复合关系（两种及以上），
//         *  如都是负面关系，取低系数，
//         *  如都是正面关系，取高系数，
//         *  如正负都有，取两次【即，对每组干支，取正面系数最高者，同时取负面系数最低者，无则不取】
//         */
//        if ($zhengmianNum + $fumianNum >= 2)
//        {
//            // 如果都是正面关系
//            if ($zhengmianNum > 0 && $fumianNum <= 0)
//            {
//
//            }// 如果都是负面关系
//            elseif ($zhengmianNum <= 0 && $fumianNum > 0)
//            {
//
//            }// 正负都有
//            else
//            {
//
//            }
//        }
        // 如与日支相合，最终系数不得低于1.2，低于1.2取1.2
        if ($this->horoscopeInstance->is_liuhe($yun[1], $dizhi[2]) || $this->horoscopeInstance->is_anhe($yun[1], $dizhi[2]))
        {
            if ($res < 1.2)
            {
                $res = 1.2;
            }
        }

        return $res;
    }

    /**
     * 计算年运雷达图数据
     */
    public function nianyunLeidaTouTu($recalculation = false)
    {
        $yishengqifu = $this->nianyunQifu(true);
        // 调取年度吉凶值（转化到30~50区间），在此基础考虑各项健康值和动应、动态，取加减
        $qifuFen = !empty($yishengqifu) ? (ceil($yishengqifu['liunian'][0]['score']) + 40) : 30;

        if ($recalculation || empty($this->bazi) || $this->horoscopeInstance === null)
        {
            $this->horoscopeInstance = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $this->advance]);
            $this->bazi = $this->horoscopeInstance->getUserData();
        }
        $res = [
            0 => ['type' => 0, 'score' => 0],// 'title' => ['恋爱', '婚姻'],
            1 => ['type' => 1, 'score' => 0],// 'title' => ['往来', '出行'],
            2 => ['type' => 2, 'score' => 0],// 'title' => ['金钱', '财富'],
            3 => ['type' => 3, 'score' => 0],// 'title' => ['工作', '事业'],
            4 => ['type' => 4, 'score' => 0],// 'title' => ['考试', '求学'],
            5 => ['type' => 5, 'score' => 0],// 'title' => ['人际', '关系'],
            6 => ['type' => 6, 'score' => 0],// 'title' => ['身心', '健康'],
            7 => ['type' => 7, 'score' => 0],// 'title' => ['家运', '亲情'],
        ];
        // 当前八字大运
        $dayun = $this->horoscopeInstance->data['dayun_now'] ?: [];
        // 当前八字流年
        $liunian = $this->horoscopeInstance->data['liunian_now'] ?: [];
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        if (!empty($dayun))
        {
            // 天干
            $tiangan[] = $dayun[0];
            // 地支
            $dizhi[] = $dayun[1];
        }

        // 健康值
        $health = $this->jiankangPower(2, $dayun, $liunian);
        $jiankangKey = 'jiankang';

        /**
         *  往来出行
         *    取比肩、正印、偏印动应系数较高者
         *    其健康值*三者取二最高动应系数和
         */
        $bijianDong = $this->dongyingScore('比肩', 2, $dayun, $liunian);
        $zhengyinDong = $this->dongyingScore('正印', 2, $dayun, $liunian);
        $pianyinDong = $this->dongyingScore('偏印', 2, $dayun, $liunian);
        $dongS = $dongSResort = [$bijianDong, $zhengyinDong, $pianyinDong];
        rsort($dongSResort);
        $maxIndex = array_search($dongSResort[0], $dongS, true);
        if ($maxIndex === 0)
        {
            $xing = $this->shishens[$this->bazi['bazi'][5]]['比肩'];
            $maxJiankang = $health[$xing]['zong_shili'];
        } elseif ($maxIndex === 1)
        {
            $xing = $this->shishens[$this->bazi['bazi'][5]]['正印'];
            $maxJiankang = $health[$xing]['zong_shili'];
        } else
        {
            $xing = $this->shishens[$this->bazi['bazi'][5]]['偏印'];
            $maxJiankang = $health[$xing]['zong_shili'];
        }
        $s = $maxJiankang * ($dongSResort[0] + $dongSResort[1]);
        $res[1]['score'] = $this->modScore($s, 1, 99);

        /**
         *  人际关系
         *    取流年干支生克关系
         *      流干与原局正克（重复一次-5）-10
         *      流干与原局合（重复一次+5） +10
         *      流支与原局冲
         *          日-10，时-8
         *          年月-6
         *      流支与原局穿
         *          日-7.时-6
         *          年月-4
         *      流支与原局合
         *          日+10，时+8
         *          年月+6
         *      流支与原局刑
         *          日-6，时-5
         *          年月-3.5
         *      流支与原局拱
         *          日+7，时+6
         *          年月+4
         *      大运也计算，以时计分
         *    相加取值
         */
        $s = 0;
        $x1 = $x2 = 0;
        if (!empty($liunian))
        {
            foreach ($tiangan as $k1 => $v1)
            {
                if ($this->yy[$liunian[0]] === $this->yy[$v1] && ($this->ke[$liunian[0]] === $v1 || $this->ke[$v1] === $liunian[0]))
                {
                    $x1++;
                    if ($x2 > 1)
                    {
                        $c = -5;
                    } else
                    {
                        $c = -10;
                    }
                    $s += $c;
                }
                if ($this->horoscopeInstance->is_wuhe($liunian[0], $v1))
                {
                    $x2++;
                    if ($x2 > 1)
                    {
                        $c = 5;
                    } else
                    {
                        $c = 10;
                    }
                    $s += $c;
                }
            }
            foreach ($dizhi as $k1 => $v1)
            {
                // 流支与原局冲
                if ($this->horoscopeInstance->is_liuchong($v1, $liunian[1]))
                {
                    switch ($k1)
                    {
                        case 0:
                        case 1:
                            $s -= 6;
                            break;
                        case 2:
                            $s -= 10 * 2;
                            break;
                        default:
                            $s -= 8;
                            break;
                    }
                }
                if ($this->horoscopeInstance->is_liuhai($v1, $liunian[1]))
                {
                    switch ($k1)
                    {
                        case 0:
                        case 1:
                            $s -= 4;
                            break;
                        case 2:
                            $s -= 7 * 2;
                            break;
                        default:
                            $s -= 6;
                            break;
                    }
                }
                if ($this->horoscopeInstance->is_liuhe($v1, $liunian[1])
                    || $this->horoscopeInstance->is_anhe($v1, $liunian[1]))
                {
                    switch ($k1)
                    {
                        case 0:
                        case 1:
                            $s += 6;
                            break;
                        case 2:
                            $s += 10 * 2;
                            break;
                        default:
                            $s += 8;
                            break;
                    }
                }
                if ($this->horoscopeInstance->is_xing($v1, $liunian[1]))
                {
                    switch ($k1)
                    {
                        case 0:
                        case 1:
                            $s -= 3.5;
                            break;
                        case 2:
                            $s -= 6 * 2;
                            break;
                        default:
                            $s -= 5;
                            break;
                    }
                }
                if ($this->horoscopeInstance->is_gong($v1, $liunian[1]))
                {
                    switch ($k1)
                    {
                        case 0:
                        case 1:
                            $s += 4;
                            break;
                        case 2:
                            $s += 7 * 2;
                            break;
                        default:
                            $s += 6;
                            break;
                    }
                }
            }
        }
        $res[5]['score'] = $this->modScore($s * 2 + 50, 1, 99);
        /**
         *  身心健康
         * 取正印食神比肩的健康值、动应
         * 正印健康值*其动应+食神健康值*其动应+比肩健康值*动应
         *  改为
         *    如有一健康低于0.5，取（其健康值-0.5）*动应系数
         *    如都高于0.5，取其健康值最小且动应不为零者，（其健康值-0.5）*动应系数
         *    如动应都是零，最终结果为75
         *    最终所得*50+50
         */
        $shishenDong = $this->dongyingScore('食神', 2, $dayun, $liunian);
        $zhengyinJiankang = $health[$this->shishens[$this->bazi['bazi'][5]]['正印']][$jiankangKey];
        $shishenJiankang = $health[$this->shishens[$this->bazi['bazi'][5]]['食神']][$jiankangKey];
        $bijianJiankang = $health[$this->shishens[$this->bazi['bazi'][5]]['比肩']][$jiankangKey];
        $dongS = $dongSResort = [$zhengyinDong, $shishenDong, $bijianDong];
        $jiankangS = $jiankangSResort = [$zhengyinJiankang, $shishenJiankang, $bijianJiankang];
        rsort($jiankangSResort);
        // 都高于0.5
        if ($jiankangSResort[2] > 0.5)
        {
            $index1 = array_search($jiankangSResort[2], $jiankangS, true);
            $index2 = array_search($jiankangSResort[1], $jiankangS, true);
            $index3 = array_search($jiankangSResort[0], $jiankangS, true);
            if ($dongS[$index1] !== 0)
            {
                $s = ($jiankangS[$index1] - 0.5) * $dongS[$index1];
                $s *= 50 + 50;
            } elseif ($dongS[$index2] !== 0)
            {
                $s = ($jiankangS[$index2] - 0.5) * $dongS[$index2];
                $s *= 50 + 50;
            } elseif ($dongS[$index3] !== 0)
            {
                $s = ($jiankangS[$index3] - 0.5) * $dongS[$index3];
                $s *= 50 + 50;
            } else
            {
                $s = 75;
            }
        } else
        {
            if ($dongS[2] !== 0 && $jiankangSResort[2] < 0.5)
            {
                $s = ($jiankangS[2] - 0.5) * $dongS[0];
                $s = ($s + 1) * 50 / 2;
            } elseif ($dongS[1] !== 0 && $jiankangSResort[1] < 0.5)
            {
                $s = ($jiankangS[1] - 0.5) * $dongS[1];
                $s = ($s + 1) * 50 / 2;
            } elseif ($dongS[0] !== 0 && $jiankangSResort[0] < 0.5)
            {
                $s = ($jiankangS[0] - 0.5) * $dongS[0];
                $s = ($s + 1) * 50 / 2;
            } else
            {
                $s = 75;
            }
        }
        $res[6]['score'] = $this->modScore($s, 1, 99);

        $zhuti = $this->zhutiNum(2, $dayun, $liunian, ['hunlian', 'caifu', 'gongzuo', 'xueye', 'fuqin', 'muqin']);
        /**
         * 各项取一征象神
         * 婚恋 女官杀男才财，取流年动应高者，如一致取流年健康小于0.5者，如都小于0.5，取流年健康较低者，如无，取流年健康较高者
         * 财富 财才，取法如上
         * 工作 官印，取法如上
         * 求学 印枭，取法如上
         * 家运 印才，取法如上
         */
        $sex = (int)$this->record['type'] === 1 ? 1 : 2;
        if ($sex === 1)
        {
            $zhengxiangShishen = ['正财', '偏财'];// 婚恋
        } else
        {
            $zhengxiangShishen = ['正官', '七杀'];// 婚恋
        }
        $type = 'hunlian';
        $xingGan1 = $this->shishens[$tiangan[2]][$zhengxiangShishen[0]];
        $xingGan2 = $this->shishens[$tiangan[2]][$zhengxiangShishen[1]];
        $dongying1 = $this->dongyingScore($zhengxiangShishen[0], 2, $dayun, $liunian);
        $dongying2 = $this->dongyingScore($zhengxiangShishen[1], 2, $dayun, $liunian);
        if ($dongying1 > $dongying2)
        {
            $zhengXiang = $xingGan1;
        } elseif ($dongying1 < $dongying2)
        {
            $zhengXiang = $xingGan2;
        } else
        {
            if ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] >= 0.5)
            {
                $zhengXiang = $xingGan1;
            } elseif ($health[$xingGan1]['jiankang'] >= 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                $zhengXiang = $xingGan2;
            } elseif ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                if ($health[$xingGan1]['jiankang'] < $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            } else
            {
                if ($health[$xingGan1]['jiankang'] > $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            }
        }
        /**
         * 取流年动态值转为0-50区间（动态值*20,50封顶，婚恋动态值计算特殊，只有星宫都有动态才50封顶，否则35封顶，且公式为动态值*18）
         */
        if ($zhuti[$type]['gong_dongtai'] > 0 && $zhuti[$type]['xing_dongtai'] > 0)
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 20;
            $dongtai = min($dongtai, 50);
        } else
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 18;
            $dongtai = min($dongtai, 35);
        }
        /**
         * 如征象十神健康大于0.5
         *   流年吉凶+该十神的健康值*动应转化值
         *   动应为零时取52分  流年吉凶+健康值✘10
         * 如征象十神健康小于0.5
         *   流年吉凶-（1-该十神的健康值）*动应转化值/2
         *   动应为零时取51分 流年吉凶+健康值✘10
         */
        if ($health[$zhengXiang]['jiankang'] >= 0.5)
        {
            $score = $qifuFen + $health[$zhengXiang]['jiankang'] * $dongtai;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        } else
        {
            $score = $qifuFen - (1 - $health[$zhengXiang]['jiankang']) * $dongtai / 2;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        }
        $res[0]['score'] = $this->modScore(ceil($score), 1, 99);

        $zhengxiangShishen = ['正财', '偏财'];// 财富
        $type = 'caifu';
        $xingGan1 = $this->shishens[$tiangan[2]][$zhengxiangShishen[0]];
        $xingGan2 = $this->shishens[$tiangan[2]][$zhengxiangShishen[1]];
        $dongying1 = $this->dongyingScore($zhengxiangShishen[0], 2, $dayun, $liunian);
        $dongying2 = $this->dongyingScore($zhengxiangShishen[1], 2, $dayun, $liunian);
        if ($dongying1 > $dongying2)
        {
            $zhengXiang = $xingGan1;
        } elseif ($dongying1 < $dongying2)
        {
            $zhengXiang = $xingGan2;
        } else
        {
            if ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] >= 0.5)
            {
                $zhengXiang = $xingGan1;
            } elseif ($health[$xingGan1]['jiankang'] >= 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                $zhengXiang = $xingGan2;
            } elseif ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                if ($health[$xingGan1]['jiankang'] < $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            } else
            {
                if ($health[$xingGan1]['jiankang'] > $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            }
        }
        /**
         * 取流年动态值转为0-50区间（动态值*20,50封顶，婚恋动态值计算特殊，只有星宫都有动态才50封顶，否则35封顶，且公式为动态值*18）
         */
        if ($zhuti[$type]['gong_dongtai'] > 0 && $zhuti[$type]['xing_dongtai'] > 0)
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 20;
            $dongtai = min($dongtai, 50);
        } else
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 18;
            $dongtai = min($dongtai, 35);
        }
        /**
         * 如征象十神健康大于0.5
         *   流年吉凶+该十神的健康值*动应转化值
         *   动应为零时取52分
         * 如征象十神健康小于0.5
         *   流年吉凶-（1-该十神的健康值）*动应转化值/2
         *   动应为零时取51分
         */
        if ($health[$zhengXiang]['jiankang'] >= 0.5)
        {
            $score = $qifuFen + $health[$zhengXiang]['jiankang'] * $dongtai;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        } else
        {
            $score = $qifuFen - (1 - $health[$zhengXiang]['jiankang']) * $dongtai / 2;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        }
        $res[2]['score'] = $this->modScore(ceil($score), 1, 99);

        $zhengxiangShishen = ['正官', '正印'];// 工作
        $xingGan1 = $this->shishens[$tiangan[2]][$zhengxiangShishen[0]];
        $xingGan2 = $this->shishens[$tiangan[2]][$zhengxiangShishen[1]];
        $dongying1 = $this->dongyingScore($zhengxiangShishen[0], 2, $dayun, $liunian);
        $dongying2 = $this->dongyingScore($zhengxiangShishen[1], 2, $dayun, $liunian);
        if ($dongying1 > $dongying2)
        {
            $zhengXiang = $xingGan1;
        } elseif ($dongying1 < $dongying2)
        {
            $zhengXiang = $xingGan2;
        } else
        {
            if ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] >= 0.5)
            {
                $zhengXiang = $xingGan1;
            } elseif ($health[$xingGan1]['jiankang'] >= 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                $zhengXiang = $xingGan2;
            } elseif ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                if ($health[$xingGan1]['jiankang'] < $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            } else
            {
                if ($health[$xingGan1]['jiankang'] > $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            }
        }
        /**
         * 取流年动态值转为0-50区间（动态值*20,50封顶，婚恋动态值计算特殊，只有星宫都有动态才50封顶，否则35封顶，且公式为动态值*18）
         */
        if ($zhuti['gongzuo1']['gong_dongtai'] + $zhuti['gongzuo1']['xing_dongtai'] >= $zhuti['gongzuo2']['gong_dongtai'] + $zhuti['gongzuo2']['xing_dongtai'])
        {
            $type = 'gongzuo1';
        } else
        {
            $type = 'gongzuo2';
        }
        if ($zhuti[$type]['gong_dongtai'] > 0 && $zhuti[$type]['xing_dongtai'] > 0)
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 20;
            $dongtai = min($dongtai, 50);
        } else
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 18;
            $dongtai = min($dongtai, 35);
        }
        /**
         * 如征象十神健康大于0.5
         *   流年吉凶+该十神的健康值*动应转化值
         *   动应为零时取52分
         * 如征象十神健康小于0.5
         *   流年吉凶-（1-该十神的健康值）*动应转化值/2
         *   动应为零时取51分
         */
        if ($health[$zhengXiang]['jiankang'] >= 0.5)
        {
            $score = $qifuFen + $health[$zhengXiang]['jiankang'] * $dongtai;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        } else
        {
            $score = $qifuFen - (1 - $health[$zhengXiang]['jiankang']) * $dongtai / 2;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        }
        $res[3]['score'] = $this->modScore(ceil($score), 1, 99);

        $zhengxiangShishen = ['正印', '偏印'];// 求学
        $type = 'xueye';
        $xingGan1 = $this->shishens[$tiangan[2]][$zhengxiangShishen[0]];
        $xingGan2 = $this->shishens[$tiangan[2]][$zhengxiangShishen[1]];
        $dongying1 = $this->dongyingScore($zhengxiangShishen[0], 2, $dayun, $liunian);
        $dongying2 = $this->dongyingScore($zhengxiangShishen[1], 2, $dayun, $liunian);
        if ($dongying1 > $dongying2)
        {
            $zhengXiang = $xingGan1;
        } elseif ($dongying1 < $dongying2)
        {
            $zhengXiang = $xingGan2;
        } else
        {
            if ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] >= 0.5)
            {
                $zhengXiang = $xingGan1;
            } elseif ($health[$xingGan1]['jiankang'] >= 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                $zhengXiang = $xingGan2;
            } elseif ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                if ($health[$xingGan1]['jiankang'] < $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            } else
            {
                if ($health[$xingGan1]['jiankang'] > $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            }
        }
        /**
         * 取流年动态值转为0-50区间（动态值*20,50封顶，婚恋动态值计算特殊，只有星宫都有动态才50封顶，否则35封顶，且公式为动态值*18）
         */
        if ($zhuti[$type]['gong_dongtai'] > 0 && $zhuti[$type]['xing_dongtai'] > 0)
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 20;
            $dongtai = min($dongtai, 50);
        } else
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 18;
            $dongtai = min($dongtai, 35);
        }
        /**
         * 如征象十神健康大于0.5
         *   流年吉凶+该十神的健康值*动应转化值
         *   动应为零时取52分
         * 如征象十神健康小于0.5
         *   流年吉凶-（1-该十神的健康值）*动应转化值/2
         *   动应为零时取51分
         */
        if ($health[$zhengXiang]['jiankang'] >= 0.5)
        {
            $score = $qifuFen + $health[$zhengXiang]['jiankang'] * $dongtai;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        } else
        {
            $score = $qifuFen - (1 - $health[$zhengXiang]['jiankang']) * $dongtai / 2;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        }
        $res[4]['score'] = $this->modScore(ceil($score), 1, 99);

        $zhengxiangShishen = ['正印', '偏财'];// 家运
        if ($zhuti['fuqin']['gong_dongtai'] + $zhuti['fuqin']['xing_dongtai'] >= $zhuti['muqin']['gong_dongtai'] + $zhuti['muqin']['xing_dongtai'])
        {
            $type = 'fuqin';
        } else
        {
            $type = 'muqin';
        }
        $xingGan1 = $this->shishens[$tiangan[2]][$zhengxiangShishen[0]];
        $xingGan2 = $this->shishens[$tiangan[2]][$zhengxiangShishen[1]];
        $dongying1 = $this->dongyingScore($zhengxiangShishen[0], 2, $dayun, $liunian);
        $dongying2 = $this->dongyingScore($zhengxiangShishen[1], 2, $dayun, $liunian);
        if ($dongying1 > $dongying2)
        {
            $zhengXiang = $xingGan1;
        } elseif ($dongying1 < $dongying2)
        {
            $zhengXiang = $xingGan2;
        } else
        {
            if ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] >= 0.5)
            {
                $zhengXiang = $xingGan1;
            } elseif ($health[$xingGan1]['jiankang'] >= 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                $zhengXiang = $xingGan2;
            } elseif ($health[$xingGan1]['jiankang'] < 0.5 && $health[$xingGan2]['jiankang'] < 0.5)
            {
                if ($health[$xingGan1]['jiankang'] < $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            } else
            {
                if ($health[$xingGan1]['jiankang'] > $health[$xingGan2]['jiankang'])
                {
                    $zhengXiang = $xingGan1;
                } else
                {
                    $zhengXiang = $xingGan2;
                }
            }
        }
        /**
         * 取流年动态值转为0-50区间（动态值*20,50封顶，婚恋动态值计算特殊，只有星宫都有动态才50封顶，否则35封顶，且公式为动态值*18）
         */
        if ($zhuti[$type]['gong_dongtai'] > 0 && $zhuti[$type]['xing_dongtai'] > 0)
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 20;
            $dongtai = min($dongtai, 50);
        } else
        {
            $dongtai = ($zhuti[$type]['gong_dongtai'] + $zhuti[$type]['xing_dongtai']) * 18;
            $dongtai = min($dongtai, 35);
        }
        /**
         * 如征象十神健康大于0.5
         *   流年吉凶+该十神的健康值*动应转化值
         *   动应为零时取52分
         * 如征象十神健康小于0.5
         *   流年吉凶-（1-该十神的健康值）*动应转化值/2
         *   动应为零时取51分
         */
        if ($health[$zhengXiang]['jiankang'] >= 0.5)
        {
            $score = $qifuFen + $health[$zhengXiang]['jiankang'] * $dongtai;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        } else
        {
            $score = $qifuFen - (1 - $health[$zhengXiang]['jiankang']) * $dongtai / 2;
            if ($dongtai === 0)
            {
                $score = $qifuFen + $health[$zhengXiang]['jiankang'] * 10;
            }
        }
        $res[7]['score'] = $this->modScore(ceil($score), 1, 99);

        // 开始处理头图
        /**
         * 头图逻辑 头图对应关系
         * 所有人对应7种图
         * 事业兴旺 0 事业值最高且过60
         * 财运亨通 1 财富值最高且过60
         * 幸福快乐 2 健康值最高且过60
         * 桃花盛开 3 婚恋值最高且过60
         * 贵人庇佑 4 人际值最高且过60
         * 学有所成 5 学业值最高且过60
         * 奋斗不息 6 其它
         */
        $toutu = 6;
        $resResort = resort($res, 'score', 'DESC');
        if ($resResort[0]['score'] > 60)
        {
            switch ($resResort[0]['type'])
            {
                case 3:
                    $toutu = 0;
                    break;
                case 2:
                    $toutu = 1;
                    break;
                case 6:
                    $toutu = 2;
                    break;
                case 0:
                    $toutu = 3;
                    break;
                case 5:
                    $toutu = 4;
                    break;
                case 4:
                    $toutu = 5;
                    break;
            }
        }
        return ['leida' => $res, 'toutu' => $toutu];
    }

    /**
     * 计算流年筛选
     * @param bool $recalculation 是否重新计算八字信息
     * @param bool $isLimit 是否只计算当前大运下的十个流年
     * @return array
     */
    public function liunianShaixuan($recalculation = true, $isLimit = false)
    {
        $res = [];
        if ($recalculation)
        {
            $this->horoscopeInstance = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $this->advance]);
            $this->bazi = $this->horoscopeInstance->getUserData2();
        }
        $shensha = $this->horoscopeInstance->param['shensha'];
        $canggan = $this->horoscopeInstance->param['canggan'];
        $shishen = $this->horoscopeInstance->param['shishen'];
        // 当前八字
        $bazi = $this->bazi['bazi'];
        // 天干
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        // 地支
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        // 性别 1男2女
        $sex = (int)$this->record['type'] === 1 ? 1 : 2;
        if ($sex === 1)
        {
            $fuqiShishen = ['正财', '偏财'];
        } else
        {
            $fuqiShishen = ['正官', '七杀'];
        }

        foreach ($this->bazi['dayun'] as $k1 => $v1)
        {
            $dy = [mb_substr($v1['name'], 0, 1), mb_substr($v1['name'], 1, 1)];
            $qinheLevel = $this->qinheLevel($dy);
            foreach ($this->bazi['liunian'][$k1] as $k2 => $v2)
            {
                if ($isLimit && ($this->advance['year'] < $v1['start_year'] || $this->advance['year'] > $v1['end_year']))
                {
                    continue;
                }
                // 当前大运下的流年
                $ln = [mb_substr($v2['name'], 0, 1), mb_substr($v2['name'], 1, 1)];
                $yearsOld = $v2['year'] - $this->record['year'];
                $newTiangan = $tiangan;
                $newDizhi = $dizhi;
                $newTiangan[] = $dy[0];
                $newDizhi[] = $dy[1];
                $hunlianZhuti = $this->zhuti('', $this->bazi['bazi'][6], $fuqiShishen, $dy, $ln, 2);
                /**
                 * 桃花年
                 * 基本征象 婚恋动态大于等于1
                 * 合 流年干
                 *   合日干1，合运干0.9，合时干0.7，合月干0.5，合年干0.3
                 * 专有征象
                 *   原局存在 配偶星的入库结构
                 *      寅未，申丑，亥辰，巳戌，每组两支同时出现
                 *      如每组其中一个为配偶星，另一个出现在流年时为桃花象1
                 *   原局存在配偶星的唯一根且非本气
                 *      该支出现在流年为桃花象1
                 * 1级1分，2级2分以下，3级大于2
                 */
                $s1 = 0;
                if ($yearsOld >= 18 && $yearsOld <= 60)
                {
                    // 流年干与天干合
                    foreach ($newTiangan as $k3 => $v3)
                    {
                        if ($this->horoscopeInstance->is_wuhe($v3, $ln[0]))
                        {
                            switch ($k3)
                            {
                                case 0:
                                    $s1 += 0.3;
                                    break;
                                case 1:
                                    $s1 += 0.5;
                                    break;
                                case 2:
                                    $s1++;
                                    break;
                                case 3:
                                    $s1 += 0.7;
                                    break;
                                case 4:
                                    $s1 += 0.9;
                                    break;
                            }
                        }
                    }
                    $fuqiBenqiNum = 0;
                    $fuqiGenNum = 0;
                    foreach ($newDizhi as $k3 => $v3)
                    {
                        foreach ($canggan[$v3] as $k4 => $v4)
                        {
                            if (in_array($shishen[$v4][$tiangan[2]], $fuqiShishen, true))
                            {
                                $fuqiGenNum++;
                                if ($k4 === 0)
                                {
                                    $fuqiBenqiNum++;
                                }
                            }
                        }
                    }
                    // 原局存在 配偶星的入库结构
                    if (($ln[1] === '未' && in_array('寅', $dizhi, true))
                        || ($ln[1] === '寅' && in_array('未', $dizhi, true))
                        || ($ln[1] === '申' && in_array('丑', $dizhi, true))
                        || ($ln[1] === '丑' && in_array('申', $dizhi, true))
                        || ($ln[1] === '亥' && in_array('辰', $dizhi, true))
                        || ($ln[1] === '辰' && in_array('亥', $dizhi, true))
                        || ($ln[1] === '巳' && in_array('戌', $dizhi, true))
                        || ($ln[1] === '戌' && in_array('巳', $dizhi, true))
                    )
                    {
                        $s1++;
                    }
                    if ($fuqiGenNum === 1 && $fuqiBenqiNum === 0)
                    {
                        $s1++;
                    }
                }
                if ($s1 > 0)
                {
                    /**
                     * 年运筛查桃花年多
                     * 逻辑进行分段处理
                     * 10-16岁 基准分大于1
                     * 16-40岁 基准分大于0.5
                     * 40岁-60岁 基准分大于1
                     * 大运过滤
                     * 最终基准分=基准分-大运婚恋动态/2
                     * 如最终基准分小于零则令其大于零
                     */
                    if (($yearsOld >= 10 && $yearsOld < 16 && $s1 > 1)
                        || ($yearsOld >= 16 && $yearsOld < 40 && $s1 > 0.5)
                        || ($yearsOld >= 40 && $yearsOld < 60 && $s1 > 1))
                    {
                        $s1 -= ($hunlianZhuti['gong_dongtai'] / 2);
                        $res[] = [
                            'type' => 1,
                            'year' => $v2['year'],
                            'level' => $this->getLevel($s1),
//                        'name' => '桃花年',
//                        'text' => '有桃花的年份，有新的感情出现，或旧的感情有进一步发展',
                        ];
                    }
                }
                /**
                 * 婚姻年
                 * 宫、夫妻星之一有得分（即，婚恋动态不为零），且印有得分（正偏印动应系数不小于1）
                 *  分级：婚恋动态值+印星动应系数
                 *      2分以下1级，3分以下2级，3分以上3级
                 * 修改后逻辑：（1和2同时满足）
                 *  1、印星动：流年干支出现印，或流年干支与原局（+运）印星（支为本气）合冲拱
                 *  2、夫妻宫动：宫支动态大于等于1
                 */
                $s2 = 0;
                $zhengyinDong = $this->dongyingScore('正印', 2, $dy, $ln);
                $pianyinDong = $this->dongyingScore('偏印', 2, $dy, $ln);
                if ($yearsOld >= 18 && $yearsOld <= 60)
                {
                    $x1 = false;
                    if ($hunlianZhuti['gong_dongtai'] >= 1)
                    {
                        if ($shishen[$ln[0]][$tiangan[2]] === '正印' || $shishen[$canggan[$ln[1]][0]][$tiangan[2]] === '正印')
                        {
                            $x1 = true;
                        }
                        if (!$x1)
                        {
                            foreach ($newDizhi as $k3 => $v3)
                            {
                                $isYinXing = in_array($shishen[$canggan[$v3][0]][$tiangan[2]], ['正印', '偏印'], true);
                                if ($isYinXing && ($this->horoscopeInstance->is_liuhe($v3, $ln[1])
                                        || $this->horoscopeInstance->is_anhe($v3, $ln[1])
                                        || $this->horoscopeInstance->is_gong($v3, $ln[1])
                                        || $this->horoscopeInstance->is_liuchong($v3, $ln[1])))
                                {
                                    $x1 = true;
                                    break;
                                }
                                if (!$x1 && $isYinXing && $this->horoscopeInstance->is_wuhe($ln[0], $canggan[$v3][0]))
                                {
                                    $x1 = true;
                                    break;
                                }
                            }
                        }
                    }
                    if ($x1)
                    {
                        $s2 = $hunlianZhuti['gong_dongtai'] + $hunlianZhuti['xing_dongtai'] + $zhengyinDong + $pianyinDong;
                    }
                }
                if ($s2 > 1)
                {
                    $res[] = [
                        'type' => 2,
                        'year' => $v2['year'],
                        'level' => $this->getLevel($s2),
//                        'name' => '婚姻年',
//                        'text' => '有婚姻可能的年份，如果有合适的对象，这一年适合谈婚论嫁、领证办酒',
                    ];
                }

                /**
                 * 财富年
                 * 流年组合没有正印受克，或有但财星综实小于印星
                 *  流年财星的动应系数
                 *  流年的亲和度 1.2-亲和等级*0.2
                 *  流年财星的健康值
                 * （健康值-0.5+亲和度）*动应系数
                 * 流年不存在吉受克的组合，但存在财才官食吉受生、劫杀枭凶受制的组合
                 *  但凡有吉受生，取该吉星健康值，有凶受制，取该凶星健康值，各值相加
                 * 1分以下1级，2分以下2级，以上三级
                 */
                $s3 = 0;
                $yiZhengyinShouke = $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln]);
                $jiankang = $this->jiankangPower(2, $dy, $ln);
                $zhengcaiGan = $this->shishens[$tiangan[2]]['正财'];
                $piancaiGan = $this->shishens[$tiangan[2]]['偏财'];
                $zhengyinGan = $this->shishens[$tiangan[2]]['正印'];
                $pianyinGan = $this->shishens[$tiangan[2]]['偏印'];
                $caiZongshi = $jiankang[$zhengcaiGan]['zong_shili'] + $jiankang[$piancaiGan]['zong_shili'];
                $yinZongshi = $jiankang[$zhengyinGan]['zong_shili'] + $jiankang[$pianyinGan]['zong_shili'];
                $zhengcaiDong = $this->dongyingScore('正财', 2, $dy, $ln);
                $piancaiDong = $this->dongyingScore('偏财', 2, $dy, $ln);
                if ($yearsOld >= 18)
                {
                    if ($yiZhengyinShouke || (!$yiZhengyinShouke && $caiZongshi < $yinZongshi))
                    {
                        $jk = ($jiankang[$zhengcaiGan]['jiankang'] + $jiankang[$piancaiGan]['jiankang']);
                        $qh = 1.2 - $qinheLevel * 0.2;
                        $dongy = $zhengcaiDong + $piancaiDong;
                        $s3 += ($jk - 0.5 + $qh) * $dongy;
                    }
                }
                if ($s3 > 1)
                {
                    $res[] = [
                        'type' => 3,
                        'year' => $v2['year'],
                        'level' => $this->getLevel($s3),
//                        'name' => '财富年',
//                        'text' => '财运较好的年份，相对于其它年份更容易发财，但有些也会伴随高额支出',
                    ];
                }

                /**
                 * 事业年
                 * 官杀状态
                 * 流年与（原局+大运）有官受生、印受生或杀有制的组合，且流年有用神
                 *  流年官杀的动应系数
                 *  流年的亲和度 1.2-亲和等级*0.2
                 *  流年官杀星的健康值
                 *  （健康值-0.5+亲和度）*动应系数
                 * 1分以下1级，2分以下2级，以上三级
                 */
                $s4 = 0;
                // 计算用神分
                $yongshen = $this->yongShen();
                if ($yearsOld >= 18 && $yearsOld <= 65)
                {
                    if ($yongshen[$ln[0]] > 0 || $yongshen[$ln[1]] > 0)
                    {
                        if ($this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                            || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                            || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                            || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                            || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                            || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                            || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln]))
                        {
                            $zhengguanGan = $this->shishens[$tiangan[2]]['正官'];
                            $qishaGan = $this->shishens[$tiangan[2]]['七杀'];
                            $zhengguanDong = $this->dongyingScore('正官', 2, $dy, $ln);
                            $qishaDong = $this->dongyingScore('七杀', 2, $dy, $ln);
                            $jk = ($jiankang[$zhengguanGan]['jiankang'] + $jiankang[$qishaGan]['jiankang']);
                            $qh = 1.2 - $qinheLevel * 0.2;
                            $dongy = $zhengguanDong + $qishaDong;
                            $s4 += ($jk - 0.5 + $qh) * $dongy;

                        }
                    }
                }
                if ($s4 > 0)
                {
                    $res[] = [
                        'type' => 4,
                        'year' => $v2['year'],
                        'level' => $this->getLevel($s4),
//                        'name' => '事业年',
//                        'text' => '事业关键年份，比其它年份更努力更容易有作为，也或者是容易升职加薪受赏识',
                    ];
                }

                /**
                 * 灾病年
                 *  流年组合有七杀+日（日干、日禄）、枭+食
                 *    同时流支与日支或日禄刑穿
                 *    流支与大运原局相冲
                 *  大运与流年干支相同
                 */
                // 禄
                $rilu = $shensha['禄神'][$tiangan[2]];
                $x1 = false;
                if ($this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '偏印', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $ln]))
                {
                    if ($this->horoscopeInstance->is_xing($ln[1], $dizhi[2])
                        || $this->horoscopeInstance->is_liuhai($ln[1], $dizhi[2])
                        || $this->horoscopeInstance->is_xing($ln[1], $rilu)
                        || $this->horoscopeInstance->is_liuhai($ln[1], $rilu))
                    {
                        $x1 = true;
                    }
                    // 流支与大运原局相冲
                    if (!$x1)
                    {
                        foreach ($newDizhi as $k3 => $v3)
                        {
                            if ($this->horoscopeInstance->is_liuchong($ln[1], $v3))
                            {
                                $x1 = true;
                                break;
                            }
                        }
                    }
                }
                if ($x1 || ($dy[0] === $ln[0] && $dy[1] === $ln[1]))
                {
                    if ($yongshen[$ln[0]] > 0 || $yongshen[$ln[1]] > 0)
                    {
                        $level = 1;
                    } else
                    {
                        $level = 2;
                    }
                    $res[] = [
                        'type' => 5,
                        'year' => $v2['year'],
                        'level' => $level,
//                        'name' => '灾病年',
//                        'text' => '身体上的忧患增加，更容易有灾祸或疾病产生的年份，但大多较轻可以避免',
                    ];
                }

                /**
                 * 变化年
                 * 1类 流年干支与本命月日时或大运干支天克地冲
                 *   冲运日为3级，其它2级
                 * 2类 流年与大运天干构成伤官见官、枭神夺食，或流年与大运地支构成伤官见官
                 *   天干构成伤官见官2级，其它1级
                 * 3类 流年干为伤官或七杀，同时流年支与本命日或时支或禄支或本气印支或本气官支相冲 2级
                 * 4类 每个大运的第一年 1级
                 */
                if ((in_array($ln[0], $this->beiKe[$tiangan[2]], true) && $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[2]))
                    || (in_array($ln[0], $this->beiKe[$dy[0]], true) && $this->horoscopeInstance->is_liuchong($ln[1], $dy[1])))
                {
                    $res[] = [
                        'type' => 6,
                        'year' => $v2['year'],
                        'level' => 3,
                    ];
                } elseif ((in_array($ln[0], $this->beiKe[$tiangan[1]], true) && $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[1]))
                    || (in_array($ln[0], $this->beiKe[$tiangan[3]], true) && $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[3])))
                {
                    $res[] = [
                        'type' => 6,
                        'year' => $v2['year'],
                        'level' => 2,
                    ];
                } else
                {
                    // 流年与大运天干构成伤官见官、枭神夺食，或流年与大运地支构成伤官见官
                    if (($this->shishens[$tiangan[2]]['伤官'] === $dy[0] && $this->shishens[$tiangan[2]]['正官'] === $ln[0])
                        || ($this->shishens[$tiangan[2]]['正官'] === $dy[0] && $this->shishens[$tiangan[2]]['伤官'] === $ln[0])
                        || ($this->shishens[$tiangan[2]]['偏印'] === $dy[0] && $this->shishens[$tiangan[2]]['食神'] === $ln[0])
                        || ($this->shishens[$tiangan[2]]['食神'] === $dy[0] && $this->shishens[$tiangan[2]]['偏印'] === $ln[0]))
                    {
                        // 天干构成伤官见官2级
                        $res[] = [
                            'type' => 6,
                            'year' => $v2['year'],
                            'level' => 2,
                        ];
                    } else
                    {
                        $isTrue = false;
                        // 或流年与大运地支构成伤官见官, 其它1级
                        foreach ($canggan[$dy[1]] as $k3 => $v3)
                        {
                            if (($this->shishens[$tiangan[2]]['伤官'] === $v3 && $this->shishens[$tiangan[2]]['正官'] === $ln[0])
                                || ($this->shishens[$tiangan[2]]['正官'] === $v3 && $this->shishens[$tiangan[2]]['伤官'] === $ln[0]))
                            {
                                $isTrue = true;
                                $res[] = [
                                    'type' => 6,
                                    'year' => $v2['year'],
                                    'level' => 1,
                                ];
                                break;
                            }
                        }
                        //3类 流年干为伤官或七杀，同时流年支与本命日或时支或禄支或本气印支或本气官支相冲 2级
                        //                 * 4类 每个大运的第一年 1级
                        if ($isTrue === false
                            && in_array($shishen[$ln[0]][$tiangan[2]], ['伤官', '七杀'], true)
                            && (
                                $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[2])
                                || $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[3])
                                || ($dizhi[0] === $rilu && $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[0]))
                                || (in_array($shishen[$canggan[$dizhi[0]][0]][$tiangan[2]], ['正印', '偏印'], true) && $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[0]))
                                || $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[3])
                                || ($dizhi[0] === $rilu && $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[0]))
                                || (in_array($shishen[$canggan[$dizhi[0]][0]][$tiangan[2]], ['正印', '偏印'], true) && $this->horoscopeInstance->is_liuchong($ln[1], $dizhi[0]))
                            ))
                        {
                            $res[] = [
                                'type' => 6,
                                'year' => $v2['year'],
                                'level' => 1,
                            ];
                        } elseif ($k2 === 0)
                        {
                            $res[] = [
                                'type' => 6,
                                'year' => $v2['year'],
                                'level' => 1,
                            ];
                        }
                    }
                }
            }
        }
        return $res;
    }

    /**
     * 年运起伏
     * 大运和流年
     */
    public function nianyunQifu($isLimit = false)
    {
        $res = [];
        $this->horoscopeInstance = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $this->advance]);
        $this->bazi = $this->horoscopeInstance->getUserData2();
        $shishen = $this->horoscopeInstance->param['shishen'];
        $canggan = $this->horoscopeInstance->param['canggan'];
        $bazi = $this->bazi['bazi'];
        // 百年大运列表
        $dayunList = $this->bazi['dayun'];
        // 百年流年列表
        $liunianList = $this->bazi['liunian'];
        // 天干
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        // 地支
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        // 原局用神分
        $yongshen = $this->yongShen();
        // 遍历大运
        foreach ($dayunList as $k1 => $v1)
        {
            if ($isLimit && ($this->advance['year'] < $v1['start_year'] || $this->advance['year'] > $v1['end_year']))
            {
                continue;
            }
            /**
             * 用神
             * 大运或流年用神得分，其中大运为【大运干支得分相加】，流年为【流年干支得分相加*0.7+大运干支得分相加*0.3】
             */
            $yungan = mb_substr($v1['name'], 0, 1);
            $yunzhi = mb_substr($v1['name'], 1, 1);
            $dayun = [$yungan, $yunzhi];
            $dayunYongshenFen = $yongshen[$yungan] + $yongshen[$yunzhi];
            $dayunJiankang = $this->jiankangPower(1, $dayun);
            $dayunQinhe = $this->qinheScore(1, $dayun);

            $dayunJishenFen = 0;
            /**
             * 以岁运干支组合计算吉神分
             * 吉神受生
             *   岁运干支（支论本气，如不说明，下同）
             *      为组合中的吉神（财才官印食） 计【10*该吉神健康值】分 如吉神在岁运，多次受生或受克，每多一次，折半计分
             *      为组合中的凶神（杀伤枭劫） 计【5*所生吉神的健康值】
             *      为比肩 计【7*食神健康值】
             * 凶神受制
             *   岁运干支（支论本气，如不说明，下同）
             *      为组合中的吉神（财才官印食） 计【10*该吉神健康值】分 如吉神在岁运，多次受生或受克，每多一次，折半计分
             *      为组合中的凶神（杀伤枭劫） 计【10*所克吉神的健康值】
             * 吉神受克
             *   岁运干支（支论本气，如不说明，下同）
             *      为组合中的吉神（财才官印食、禄比） 计【-10*（1-该吉神健康值）】分 如吉神在岁运，多次受生或受克，每多一次，折半计分
             *      为组合中的凶神（杀伤枭劫比） 计【-10*（1-所克吉神的健康值）】分
             * 吉神合日
             *   岁运天干五合日干 计 【10*该干健康值】分
             *   岁运地支六合、暗合日支，且该支本气才财官印食 计 10*该吉神健康值 分
             *   岁运地支六合、暗合日支，且岁运干为财才官印食 计 7*该干吉神健康值 分
             * 注意，如一组合同时是吉受生和凶受制（如杀印），仅计算一次分
             * 注意，吉神合日不属于组合，单独计分不受其他影响
             * 以上流程所有得分相加为岁运的吉神分
             * 岁运公式调整为 （用神分+吉神分）*亲和系数
             * 得分调整至-10~10区间
             */
            $dayunGanShishen = $shishen[$dayun[0]][$tiangan[2]];// 大运天干十神
            $dayunBenqi = $canggan[$dayun[1]][0];// 大运地支本气
            $dayunBenqiShishen = $shishen[$canggan[$dayun[1]][0]][$tiangan[2]];// 大运地支本气十神
            $zhengyinGan = $this->shishens[$bazi[5]]['正印'];
            $pianyinGan = $this->shishens[$bazi[5]]['偏印'];
            $zhengcaiGan = $this->shishens[$bazi[5]]['正财'];
            $piancaiGan = $this->shishens[$bazi[5]]['偏财'];
            $shishenGan = $this->shishens[$bazi[5]]['食神'];
            $shangguanGan = $this->shishens[$bazi[5]]['伤官'];
            $zhengguanGan = $this->shishens[$bazi[5]]['正官'];
            $qishaGan = $this->shishens[$bazi[5]]['七杀'];
            $bijianGan = $this->shishens[$bazi[5]]['比肩'];
            $jiecaiGan = $this->shishens[$bazi[5]]['劫财'];
            // 吉神受生
            if ($this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '比肩', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
            {
                $jiShenX = 1;
                // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                if (in_array($dayunGanShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$dayun[0]]['jiankang'] * $jiShenX;
                    $jiShenX = 0.5;
                }
                // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                if (in_array($dayunBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$dayunBenqi]['jiankang'] * $jiShenX;
                }
                // 为组合中的凶神（杀伤枭劫） 计【5*所生吉神的健康值】
                if (($dayunGanShishen === '七杀' && $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $dayunJishenFen += 5 * $dayunJiankang[$zhengyinGan]['jiankang'];
                }
                if ($dayunGanShishen === '伤官' && $this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 5 * $dayunJiankang[$zhengcaiGan]['jiankang'];
                }
                if ($dayunGanShishen === '伤官' && $this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 5 * $dayunJiankang[$piancaiGan]['jiankang'];
                }
                if ($dayunGanShishen === '劫财' && $this->zuhePanding(['type' => 1, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 5 * $dayunJiankang[$piancaiGan]['jiankang'];
                }
                // 为比肩 计【7*食神健康值】
                if ($dayunGanShishen === '比肩')
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$shishenGan]['jiankang'] * $jiShenX;
                }
                // 为比肩 计【7*食神健康值】
                if ($dayunBenqiShishen === '比肩')
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$dayunBenqi]['jiankang'] * $jiShenX;
                }
            }
            // 凶神受制
            if ($this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
            {
                $jiShenX = 1;
                // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                if (in_array($dayunGanShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$dayun[0]]['jiankang'] * $jiShenX;
                    $jiShenX = 0.5;
                }
                // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                if (in_array($dayunBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$dayunBenqi]['jiankang'] * $jiShenX;
                }
                // 为组合中的凶神（杀伤枭劫） 计【10*所生吉神的健康值】
                if (($dayunGanShishen === '七杀' && $this->zuhePanding(['type' => 2, 'xing1' => '食神', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$shishenGan]['jiankang'];
                }
                if (($dayunGanShishen === '七杀' && $this->zuhePanding(['type' => 2, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$zhengyinGan]['jiankang'];
                }
                if ($dayunGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$zhengyinGan]['jiankang'];
                }
                if ($dayunGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$zhengcaiGan]['jiankang'];
                }
                if ($dayunGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$piancaiGan]['jiankang'];
                }
//                if($dayunGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
//                {
//                    $dayunJishenFen += 10 * $dayunJiankang[$zhengncaiGan]['jiankang'];
//                }
                if ($dayunGanShishen === '偏印' && $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$piancaiGan]['jiankang'];
                }
//                if($dayunGanShishen === '偏印' && $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
//                {
//                    $dayunJishenFen += 10 * $dayunJiankang[$piancaiGan]['jiankang'];
//                }
                if ($dayunGanShishen === '劫财' && $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$zhengguanGan]['jiankang'];
                }
                if ($dayunGanShishen === '劫财' && $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$qishaGan]['jiankang'];
                }
                if ($dayunGanShishen === '劫财' && $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$shishenGan]['jiankang'];
                }
            }
            // 吉神受克
            if ($this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
            {
                $jiShenX = 1;
                // 为组合中的吉神（财才官印食、禄比） 计【-10*（1-该吉神健康值）】分 如吉神在岁运，多次受生或受克，每多一次，折半计分
                if (in_array($dayunGanShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$dayun[0]]['jiankang']) * $jiShenX;
                    $jiShenX = 0.5;
                }
                // 为组合中的吉神（财才官印食、禄比） 计【-10*（1-该吉神健康值）】分 如吉神在岁运，多次受生或受克，每多一次，折半计分
                if (in_array($dayunBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$dayunBenqi]['jiankang']) * $jiShenX;
                }
                // 为组合中的凶神（杀伤枭劫比） 计【-10*（1-所克吉神的健康值）】分
                if (($dayunGanShishen === '七杀' && $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$zhengyinGan]['jiankang']);
                }
                if (($dayunGanShishen === '七杀' && $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$bijianGan]['jiankang']);
                }
//                if (($dayunGanShishen === '七杀' && $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
//                {
//                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$zhengyinGan]['jiankang']);
//                }
                if ($dayunGanShishen === '伤官' && $this->zuhePanding(['type' => 0, 'xing1' => '伤官', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$zhengguanGan]['jiankang']);
                }
                if ($dayunGanShishen === '偏印' && $this->zuhePanding(['type' => 0, 'xing1' => '偏印', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$shishenGan]['jiankang']);
                }
                if ($dayunGanShishen === '劫财' && $this->zuhePanding(['type' => 0, 'xing1' => '劫财', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $dayunJishenFen += -10 * (1 - $dayunJiankang[$zhengcaiGan]['jiankang']);
                }
            }
            // 吉神合日
            // 岁运天干五合日干 计 【10*该干健康值】分
            if ($this->horoscopeInstance->is_wuhe($dayun[0], $tiangan[2]))
            {
                $dayunJishenFen += 10 * $dayunJiankang[$dayun[0]]['jiankang'];
            }
            // 岁运地支六合、暗合日支，
            if (($this->horoscopeInstance->is_liuhe($dayun[1], $dizhi[2]) || $this->horoscopeInstance->is_anhe($dayun[1], $dizhi[2])))
            {
                // 且该支本气才财官印食 计 10*该吉神健康值 分
                if (in_array($dayunBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$dayunBenqi]['jiankang'];
                }
                // 且岁运干为财才官印食 计 7*该干吉神健康值 分
                if (in_array($dayun[0], ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    $dayunJishenFen += 10 * $dayunJiankang[$dayun[0]]['jiankang'];
                }
            }
            $dayunFen = ($dayunYongshenFen + $dayunJishenFen) * $dayunQinhe;
            $res['dayun'][] = [
                'name' => $v1['name'],
                'score' => $this->modScore($dayunFen, 1, 40),
                'start' => $v1['start_year'],
                'end' => $v1['end_year'],
            ];

            // 遍历流年
            foreach ($liunianList[$k1] as $k2 => $v2)
            {
                if ($isLimit && $this->advance['year'] * 1 !== $v2['year'])
                {
                    continue;
                }
                /**
                 * 用神
                 * 大运或流年用神得分，其中大运为【大运干支得分相加】，流年为【流年干支得分相加*0.7+大运干支得分相加*0.3】
                 */
                $liugan = mb_substr($v2['name'], 0, 1);
                $liuzhi = mb_substr($v2['name'], 1, 1);
                $liunian = [$liugan, $liuzhi];
                $liunianYongshenFen = $yongshen[$liugan] + $yongshen[$liuzhi];
                $liunianYongshenFen = $liunianYongshenFen * 0.7 + $dayunYongshenFen * 0.3;
                $liunianJiankang = $this->jiankangPower(2, $dayun, $liunian);
                $liunianQinhe = $this->qinheScore(2, $dayun, $liunian);

                $liunianJishenFen = 0;
//                /**
//                 * 吉神分
//                 * 大运或流年各吉神健康*其动应系数（系数零忽略不计）后相加取和，吉神包括 比肩（日干）、食神、正官、正印、正财，在流年，大运动应系数*0.3，流年动应系数*0.7
//                 */
//                foreach ($tiangan as $k3 => $v3)
//                {
//                    if ($k3 === 2) continue;
//                    $ganshen = $this->horoscopeInstance->param['shishen'][$v3][$tiangan[2]];
//                    if (in_array($ganshen, ['比肩', '食神', '正官', '正印', '正财'], true))
//                    {
//                        $dayunDongying = $this->dongyingScore($ganshen, 1, $dayun);
//                        $liunianDongying = $this->dongyingScore($ganshen, 2, $dayun, $liunian);
//                        $liunianDongying = $dayunDongying * 0.3 + $liunianDongying * 0.7;
//                        $liunianJishenFen = $liunianJiankang[$v3]['jiankang'] * $liunianDongying;
//                    }
//                }
//                /**
//                 * 基本公式：（用神分+吉神分*动应系数）*亲和系数
//                 */
//                $liunianFen = ($liunianYongshenFen + $liunianJishenFen) * $liunianQinhe;
                $liunianGanShishen = $shishen[$dayun[0]][$tiangan[2]];// 流年天干十神
                $liunianBenqi = $canggan[$dayun[1]][0];// 流年地支本气
                $liunianBenqiShishen = $shishen[$canggan[$dayun[1]][0]][$tiangan[2]];// 流年地支本气十神
                $newTiangan = $tiangan;
                $newDizhi = $dizhi;
                $newTiangan[] = $dayun[0];
                $newDizhi[] = $dayun[1];
                // 吉神受生
                if ($this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '比肩', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                {
                    $jiShenX = 1;
                    // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                    if (in_array($liunianGanShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$liunian[0]]['jiankang'] * $jiShenX;
                        $jiShenX = 0.5;
                    }
                    // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                    if (in_array($liunianBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$liunianBenqi]['jiankang'] * $jiShenX;
                    }
                    // 为组合中的凶神（杀伤枭劫） 计【5*所生吉神的健康值】
                    if (($liunianGanShishen === '七杀' && $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])))
                    {
                        $liunianJishenFen += 5 * $liunianJiankang[$zhengyinGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '伤官' && $this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 5 * $liunianJiankang[$zhengcaiGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '伤官' && $this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 5 * $liunianJiankang[$piancaiGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '劫财' && $this->zuhePanding(['type' => 1, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 5 * $liunianJiankang[$piancaiGan]['jiankang'];
                    }
                    // 为比肩 计【7*食神健康值】
                    if ($liunianGanShishen === '比肩')
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$shishenGan]['jiankang'] * $jiShenX;
                    }
                    // 为比肩 计【7*食神健康值】
                    if ($liunianBenqiShishen === '比肩')
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$liunianBenqi]['jiankang'] * $jiShenX;
                    }
                }
                // 凶神受制
                if ($this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                {
                    $jiShenX = 1;
                    // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                    if (in_array($liunianGanShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$liunian[0]]['jiankang'] * $jiShenX;
                        $jiShenX = 0.5;
                    }
                    // 为组合中的吉神（财才官印食） 计【10*该吉神健康值】
                    if (in_array($liunianBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$liunianBenqi]['jiankang'] * $jiShenX;
                    }
                    // 为组合中的凶神（杀伤枭劫） 计【10*所生吉神的健康值】
                    if (($liunianGanShishen === '七杀' && $this->zuhePanding(['type' => 2, 'xing1' => '食神', 'xing2' => '七杀', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$shishenGan]['jiankang'];
                    }
                    if (($liunianGanShishen === '七杀' && $this->zuhePanding(['type' => 2, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$zhengyinGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$zhengyinGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$zhengcaiGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$piancaiGan]['jiankang'];
                    }
//                if($liunianGanShishen === '伤官' && $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
//                {
//                    $liunianJishenFen += 10 * $liunianJiankang[$zhengncaiGan]['jiankang'];
//                }
                    if ($liunianGanShishen === '偏印' && $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$piancaiGan]['jiankang'];
                    }
//                if($liunianGanShishen === '偏印' && $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
//                {
//                    $liunianJishenFen += 10 * $liunianJiankang[$piancaiGan]['jiankang'];
//                }
                    if ($liunianGanShishen === '劫财' && $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$zhengguanGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '劫财' && $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$qishaGan]['jiankang'];
                    }
                    if ($liunianGanShishen === '劫财' && $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$shishenGan]['jiankang'];
                    }
                }
                // 吉神受克
                if ($this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                {
                    $jiShenX = 1;
                    // 为组合中的吉神（财才官印食、禄比） 计【-10*（1-该吉神健康值）】分 如吉神在岁运，多次受生或受克，每多一次，折半计分
                    if (in_array($liunianGanShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += -10 * (1 - $liunianJiankang[$liunian[0]]['jiankang']) * $jiShenX;
                        $jiShenX = 0.5;
                    }
                    // 为组合中的吉神（财才官印食、禄比） 计【-10*（1-该吉神健康值）】分 如吉神在岁运，多次受生或受克，每多一次，折半计分
                    if (in_array($liunianBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += -10 * (1 - $liunianJiankang[$liunianBenqi]['jiankang']) * $jiShenX;
                    }
                    // 为组合中的凶神（杀伤枭劫比） 计【-10*（1-所克吉神的健康值）】分
                    if (($liunianGanShishen === '七杀' && $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])))
                    {
                        $liunianJishenFen += -10 * (1 - $liunianJiankang[$zhengyinGan]['jiankang']);
                    }
                    if (($liunianGanShishen === '七杀' && $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])))
                    {
                        $liunianJishenFen += -10 * (1 - $liunianJiankang[$bijianGan]['jiankang']);
                    }
//                if (($liunianGanShishen === '七杀' && $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian])))
//                {
//                    $liunianJishenFen += -10 * (1 - $liunianJiankang[$zhengyinGan]['jiankang']);
//                }
                    if ($liunianGanShishen === '伤官' && $this->zuhePanding(['type' => 0, 'xing1' => '伤官', 'xing2' => '正官', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += -10 * (1 - $liunianJiankang[$zhengguanGan]['jiankang']);
                    }
                    if ($liunianGanShishen === '偏印' && $this->zuhePanding(['type' => 0, 'xing1' => '偏印', 'xing2' => '食神', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += -10 * (1 - $liunianJiankang[$shishenGan]['jiankang']);
                    }
                    if ($liunianGanShishen === '劫财' && $this->zuhePanding(['type' => 0, 'xing1' => '劫财', 'xing2' => '正财', 'tiangan' => $newTiangan, 'dizhi' => $newDizhi, 'yun' => $liunian]))
                    {
                        $liunianJishenFen += -10 * (1 - $liunianJiankang[$zhengcaiGan]['jiankang']);
                    }
                }
                // 吉神合日
                // 岁运天干五合日干 计 【10*该干健康值】分
                if ($this->horoscopeInstance->is_wuhe($liunian[0], $tiangan[2]))
                {
                    $liunianJishenFen += 10 * $liunianJiankang[$liunian[0]]['jiankang'];
                }
                // 岁运地支六合、暗合日支，
                if (($this->horoscopeInstance->is_liuhe($liunian[1], $dizhi[2]) || $this->horoscopeInstance->is_anhe($liunian[1], $dizhi[2])))
                {
                    // 且该支本气才财官印食 计 10*该吉神健康值 分
                    if (in_array($liunianBenqiShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$liunianBenqi]['jiankang'];
                    }
                    // 且岁运干为财才官印食 计 7*该干吉神健康值 分
                    if (in_array($liunian[0], ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $liunianJishenFen += 10 * $liunianJiankang[$liunian[0]]['jiankang'];
                    }
                }
                $liunianFen = ($liunianYongshenFen + $liunianJishenFen) * $liunianQinhe;

                $res['liunian'][] = [
                    'name' => $v2['name'],
                    'score' => $this->modScore($liunianFen, 1, 40),
                    'start' => $v1['start_year'] + $k2,
                    'end' => '',
                ];
            }
        }
        // 一生起伏分数调整
        foreach ($res as $k1 => $v1)
        {
            foreach ($v1 as $k2 => $v2)
            {
                $score = $v2['score'] / 2 - 10;
                $res[$k1][$k2]['score'] = $score;
            }
        }

        return $res;
    }

    /**
     * 人生阶段
     * @return array
     */
    public function renshengjieduan()
    {
        $texts = $years = [];
        $topic = [
            'code' => '',
            'start' => '',
            'end' => '',
            'index' => '',
        ];
        $this->horoscopeInstance = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $this->advance]);
        $this->bazi = $this->horoscopeInstance->getUserData2();
        $shensha = $this->horoscopeInstance->param['shensha'];
        $canggan = $this->horoscopeInstance->param['canggan'];
        $shishen = $this->horoscopeInstance->param['shishen'];
        // 当前八字
        $bazi = $this->bazi['bazi'];
        // 当前八字大运
        $dayun = $this->horoscopeInstance->data['dayun_now'];
        // 天干
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        // 地支
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        $allTiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7], $dayun[0]];
        $allDizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8], $dayun[1]];
        // 计算亲和等级
        $qinheLevel = $this->qinheLevel($dayun);
        // 计算主题得分（动态值、负面值）
        $zhuti = $this->zhutiNum(1, $dayun);
        // 计算健康值
        $jiankang = $this->jiankangPower(1, $dayun);
        // 计算用神分
        $yongshen = $this->yongShen();
        // 计算气力值
        $power = $this->tianganPower();
        // 计算印星动应系数
        $yinDongying = $this->dongyingScore('正印', 1, $dayun);
        // 禄
        $rilu = $shensha['禄神'][$tiangan[2]];
        // 夫妻星：男命正财偏财 女命正官七杀  夫妻宫：日支
        $sex = (int)$this->record['type'] === 1 ? 1 : 2;
        if ($sex === 1)
        {
            $fuqiXing = ['正财', '偏财'];
        } else
        {
            $fuqiXing = ['正官', '七杀'];
        }
        $fuqiGan1 = $this->shishens[$bazi[5]][$fuqiXing[0]];
        $fuqiGan2 = $this->shishens[$bazi[5]][$fuqiXing[1]];
        $fuqiGong = $bazi[6];
        $shishenList = [];
        foreach ($allTiangan as $k1 => $v1)
        {
            if ($k1 === 2) continue;
            $shishenList[] = $shishen[$v1][$bazi[5]];
        }
        foreach ($allDizhi as $k1 => $v1)
        {
            foreach ($this->horoscopeInstance->param['canggan'][$v1] as $k2 => $v2)
            {
                $shishenList[] = $shishen[$v2][$bazi[5]];
            }
        }
        $dizhiBenqiList = [];
        foreach ($dizhi as $k1 => $v1)
        {
            $dizhiBenqiList[] = $canggan[$v1][0];
        }
        $zhengyinGan = $this->shishens[$bazi[5]]['正印'];
        $pianyinGan = $this->shishens[$bazi[5]]['偏印'];
        $zhengcaiGan = $this->shishens[$bazi[5]]['正财'];
        $piancaiGan = $this->shishens[$bazi[5]]['偏财'];
        $shishenGan = $this->shishens[$bazi[5]]['食神'];
        $shangguanGan = $this->shishens[$bazi[5]]['伤官'];
        $zhengguanGan = $this->shishens[$bazi[5]]['正官'];
        $qishaGan = $this->shishens[$bazi[5]]['七杀'];
        $bijianGan = $this->shishens[$bazi[5]]['比肩'];
        $jiecaiGan = $this->shishens[$bazi[5]]['劫财'];
        $yunGanShishen = $shishen[$dayun[0]][$tiangan[2]];
        $yunBenqi = $this->horoscopeInstance->param['canggan'][$dayun[1]][0];
        $yunBenqiShishen = $shishen[$yunBenqi][$tiangan[2]];

        // 计算某某之运
        $jiDeKe = [
            '日干' => '七杀',
            '食神' => '偏印',
            '正官' => '伤官',
            '正印' => '正财',
            '正财' => '劫财',
            '偏财' => '比肩',
        ];
        $jiShoueKe = [
            '七杀' => '日干',
            '偏印' => '食神',
            '伤官' => '正官',
            '正财' => '正印',
            '劫财' => '正财',
            '比肩' => '偏财',
        ];
        $jishenList = [
            ['shishen' => '食神', 'jiankang' => $jiankang[$shishenGan]['jiankang']],
            ['shishen' => '正官', 'jiankang' => $jiankang[$zhengguanGan]['jiankang']],
            ['shishen' => '正印', 'jiankang' => $jiankang[$zhengyinGan]['jiankang']],
            ['shishen' => '正财', 'jiankang' => $jiankang[$zhengcaiGan]['jiankang']],
            ['shishen' => '偏财', 'jiankang' => $jiankang[$piancaiGan]['jiankang']]
        ];
        // 吉神健康排序
        $jishenJiankangResortList = resort($jishenList, 'jiankang', 'ASC');
        // 出现吉受克组合优先，如果运支合日支不算
        if (isset($jiShoueKe[$yunGanShishen]) || isset($jiDeKe[$yunGanShishen]))
        {
            $isDizhiJiShouKe = false;
            // 或与日支、日禄冲穿刑
            if (!$this->horoscopeInstance->is_liuhe($dizhi[2], $dayun[1])
                && !$this->horoscopeInstance->is_anhe($dizhi[2], $dayun[1])
                && ($this->horoscopeInstance->is_liuchong($dizhi[2], $dayun[1])
                    || $this->horoscopeInstance->is_liuhai($dizhi[2], $dayun[1])
                    || $this->horoscopeInstance->is_xing($dizhi[2], $dayun[1])
                    || $this->horoscopeInstance->is_liuchong($rilu, $dayun[1])
                    || $this->horoscopeInstance->is_liuhai($rilu, $dayun[1])
                    || $this->horoscopeInstance->is_xing($rilu, $dayun[1])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])))
            {
                $isDizhiJiShouKe = true;
            }
            if ((isset($jiShoueKe[$yunGanShishen])
                    && $this->zuhePanding(['type' => 0, 'xing1' => $yunGanShishen, 'xing2' => $jiShoueKe[$yunGanShishen], 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                || (isset($jiDeKe[$yunGanShishen])
                    && $this->zuhePanding(['type' => 0, 'xing1' => $yunGanShishen, 'xing2' => $jiDeKe[$yunGanShishen], 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])))
            {
                // 天干吉受克，地支也出现吉受克或与日支、日禄冲穿刑（如与日支合不在此列）
                if ($isDizhiJiShouKe)
                {
                    if ($this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                    {
                        $topic['code'] = $sex === 1 ? '01' : '02';
                    } else
                    {
                        // 优先取健康值最小的
                        foreach ($jishenJiankangResortList as $k1 => $v1)
                        {
                            if ($topic['code'] === ''
                                && $this->zuhePanding(['type' => 0, 'xing1' => $v1['shishen'], 'xing2' => $jiDeKe[$v1['shishen']], 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                            {
                                switch ($v1['shishen'])
                                {
                                    case '食神':
                                        // 学思之运（用神+运干支枭）
                                        // 贪欢之运（用神+运干支食神）
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '偏印')
                                            {
                                                $topic['code'] = '04';
                                            } elseif ($yunGanShishen === '食神')
                                            {
                                                $topic['code'] = '05';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '偏印')
                                                {
                                                    $topic['code'] = '04';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '食神')
                                                {
                                                    $topic['code'] = '05';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = '03';
                                        }
                                        break;
                                    case '正官':
                                        // 破立之运 06 07
                                        // 求索之运（用神+运干支官）08 09
                                        // 变革之运（用神+运干支伤）10 11
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '正官')
                                            {
                                                $topic['code'] = $sex === 1 ? '08' : '09';
                                            } elseif ($yunGanShishen === '伤官')
                                            {
                                                $topic['code'] = $sex === 1 ? '10' : '11';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '正官')
                                                {
                                                    $topic['code'] = $sex === 1 ? '08' : '09';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '伤官')
                                                {
                                                    $topic['code'] = $sex === 1 ? '10' : '11';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = $sex === 1 ? '06' : '07';
                                        }
                                        break;
                                    case '正印':
                                        // 飘蓬之运 12
                                        // 依恋之运(用神+运干支印) 13
                                        // 辛勤之运(用神+运干支财) 14 15
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '正印')
                                            {
                                                $topic['code'] = '13';
                                            } elseif ($yunGanShishen === '正财')
                                            {
                                                $topic['code'] = $sex === 1 ? '14' : '15';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '正印')
                                                {
                                                    $topic['code'] = '13';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '正财')
                                                {
                                                    $topic['code'] = $sex === 1 ? '14' : '15';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = 12;
                                        }
                                        break;
                                    case '正财':
                                        // 破耗之运 18 19
                                        // 理财之运(用神+运干支劫) 16 17
                                        // 辛勤之运(用神+运干支财) 14 15
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '劫财')
                                            {
                                                $topic['code'] = $sex === 1 ? '16' : '17';
                                            } elseif ($yunGanShishen === '正财')
                                            {
                                                $topic['code'] = $sex === 1 ? '14' : '15';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '劫财')
                                                {
                                                    $topic['code'] = $sex === 1 ? '16' : '17';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '正财')
                                                {
                                                    $topic['code'] = $sex === 1 ? '14' : '15';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = $sex === 1 ? '18' : '19';
                                        }
                                        break;
                                    case '偏财':
                                        // 飞财之运
                                        if ($yongshen[$piancaiGan] > 0)
                                        {
                                            $topic['code'] = $sex === 1 ? '20' : '21';
                                            break;
                                        }
                                        $topic['code'] = $sex === 1 ? '16' : '17';
                                        break;
                                }
                            }
                            if ($topic['code'] !== '')
                            {
                                break;
                            }
                        }
                    }
                } else
                {
                    // 天干吉受克，地支未出现以上征象，受克吉神健康度，吉神包含（正财、偏财、正官、正印、食神、日干）
                    // 吉受克组合
                    // 财+劫，才+比，官+伤，食+枭，印+财，杀+日干，杀+同性根，杀+禄
                    if ($this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        if ($jiankang[$tiangan[2]]['jiankang'] < 0.5)
                        {
                            // 磨砺之运 01 02
                            $topic['code'] = $sex === 1 ? '01' : '02';
                        } else
                        {
                            switch ($yunGanShishen)
                            {
                                case '正官':
                                    // 名位 27 28
                                    $topic['code'] = $sex === 1 ? '27' : '28';
                                    break;
                                case '七杀':
                                    if ($yongshen[$qishaGan] > 0)
                                    {
                                        // 奋进  46 47
                                        $topic['code'] = $sex === 1 ? '46' : '47';
                                    } else
                                    {
                                        // 磨砺 01 02
                                        $topic['code'] = $sex === 1 ? '01' : '02';
                                    }
                                    break;
                                case '正财':
                                    // 积富 26
                                    $topic['code'] = '26';
                                    break;
                                case '偏财':
                                    // 飞财 20 21
                                    $topic['code'] = $sex === 1 ? '20' : '21';
                                    break;
                                case '食神':
                                    // 欢愉
                                    $topic['code'] = '30';
                                    break;
                                case '伤官':
                                    if ($yongshen[$shangguanGan] > 0)
                                    {
                                        // 开创 50
                                        $topic['code'] = '50';
                                    } else
                                    {
                                        // 技艺 51
                                        $topic['code'] = '51';
                                    }
                                    break;
                                case '比肩':
                                    // 【按天干无组合运干为比肩处理】
                                    // 运支本气为吉
                                    if (in_array($yunBenqiShishen, ['正官', '正财', '偏财', '食神', '正印'], true))
                                    {
                                        switch ($yunGanShishen)
                                        {
                                            case '正财':
                                                // 积富之运 26
                                                $topic['code'] = '26';
                                                break;
                                            case '偏财':
                                                // 飞财之运 20 21
                                                $topic['code'] = $sex === 1 ? '20' : '21';
                                                break;
                                            case '正官':
                                                // 名位之运 27 28
                                                $topic['code'] = $sex === 1 ? '27' : '28';
                                                break;
                                            case '正印':
                                                // 安恬之运 29
                                                $topic['code'] = '29';
                                                break;
                                            case '食神':
                                                // 欢愉之运 30
                                                $topic['code'] = '30';
                                                break;
                                        }
                                    }// 运支本气为凶
                                    elseif (in_array($yunBenqiShishen, ['七杀', '伤官', '偏印', '劫财'], true))
                                    {
                                        switch ($yunGanShishen)
                                        {
                                            case '七杀':
                                                if ($isDizhiJishengXiongzhi)
                                                {
                                                    // 英豪之运(杀为用) 45
                                                    // 奋进之运(杀不为用) 46 47
                                                    if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                                                    {
                                                        $topic['code'] = '45';
                                                    } else
                                                    {
                                                        $topic['code'] = $sex === 1 ? '46' : '47';
                                                    }
                                                } else
                                                {
                                                    // 奋进之运(杀为用) 46 47
                                                    // 攀山之运(杀不为用) 48
                                                    if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                                                    {
                                                        $topic['code'] = $sex === 1 ? '46' : '47';
                                                    } else
                                                    {
                                                        $topic['code'] = '48';
                                                    }
                                                }
                                                break;
                                            case '伤官':
                                                if (in_array($yunBenqiShishen, ['正印', '偏印'], true))
                                                {
                                                    // 技艺之运 51
                                                    $topic['code'] = '51';
                                                } elseif (in_array($yunBenqiShishen, ['正财', '偏财', '七杀'], true))
                                                {
                                                    // 开创之运 50
                                                    $topic['code'] = '50';
                                                }
                                                break;
                                            case '偏印':
                                                if (in_array($yunBenqiShishen, ['正财', '偏财'], true))
                                                {
                                                    // 谋略之运 55
                                                    $topic['code'] = '55';
                                                } else
                                                {
                                                    // 研学之运 54
                                                    $topic['code'] = '54';
                                                }
                                                break;
                                            case '劫财':
                                                if ($yunBenqiShishen === '偏财')
                                                {
                                                    // 飞财之运 20 21
                                                    $topic['code'] = $sex === 1 ? '20' : '21';
                                                } elseif ($yunBenqiShishen === '七杀')
                                                {
                                                    // 奋进之运 46 47
                                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                                } elseif ($yunBenqiShishen === '正官')
                                                {
                                                    // 得助之运 53
                                                    $topic['code'] = '53';
                                                }
                                                break;
                                        }
                                    }
                                    break;
                                case '劫财':
                                    if ($yongshen[$jiecaiGan] > 0)
                                    {
                                        // 得助 53
                                        $topic['code'] = '53';
                                    } else
                                    {
                                        // 破耗 18 19
                                        $topic['code'] = $sex === 1 ? '18' : '19';
                                    }
                                    break;
                                case '正印':
                                    // 安恬 29
                                    $topic['code'] = '29';
                                    break;
                                case '偏印':
                                    // 思虑 03
                                    $topic['code'] = '03';
                                    break;
                            }
                        }
                    } elseif ($this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        // 破耗之运 18 19
                        if ($jiankang[$zhengcaiGan]['jiankang'] < 0.5)
                        {
                            $topic['code'] = $sex === 1 ? '18' : '19';
                        }
                    } elseif ($this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        // 理财之运 16 17
                        if ($jiankang[$piancaiGan]['jiankang'] < 0.5)
                        {
                            $topic['code'] = $sex === 1 ? '16' : '17';
                        }
                    } elseif ($this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        // 破立之运 06 07
                        if ($jiankang[$zhengguanGan]['jiankang'] < 0.5)
                        {
                            $topic['code'] = $sex === 1 ? '06' : '07';
                        }
                    } elseif ($this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        // 飘蓬之运 12
                        if ($jiankang[$zhengyinGan]['jiankang'] < 0.5)
                        {
                            $topic['code'] = '12';
                        }
                    } elseif ($this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        if ($jiankang[$shishenGan]['jiankang'] < 0.5)
                        {
                            // 思虑之运 03
                            $topic['code'] = '03';
                        }
                    }
                }

            } elseif ((isset($jiShoueKe[$yunBenqiShishen])
                    && $this->zuhePanding(['type' => 0, 'xing1' => $yunBenqiShishen, 'xing2' => $jiShoueKe[$yunBenqiShishen], 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']]))
                || (isset($jiDeKe[$yunBenqiShishen])
                    && $this->zuhePanding(['type' => 0, 'xing1' => $yunBenqiShishen, 'xing2' => $jiDeKe[$yunBenqiShishen], 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']]))
                || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']])
                || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']])
                || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']]))
            {
                if (in_array($yunGanShishen, ['七杀', '伤官', '偏印', '劫财'], true))
                {
                    if ($this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $dizhiBenqiList, 'dizhi' => [], 'yun' => [$yunBenqi, '']]))
                    {
                        // 傲骨之运(运干为劫)  22
                        if ($yunGanShishen === '劫财')
                        {
                            $topic['code'] = '22';
                        } else
                        {
                            // 23 24
                            $topic['code'] = $sex === 1 ? '23' : '24';
                        }
                    } else
                    {
                        // 优先取健康值最小的
                        foreach ($jishenJiankangResortList as $k1 => $v1)
                        {
                            if ($topic['code'] === ''
                                && $this->zuhePanding(['type' => 0, 'xing1' => $v1['shishen'], 'xing2' => $jiDeKe[$v1['shishen']], 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                            {
                                switch ($v1['shishen'])
                                {
                                    case '食神':
                                        // 风浪之运（运干为杀） 23 24
                                        // 思虑之运 03
                                        if ($yunGanShishen === '七杀')
                                        {
                                            $topic['code'] = $sex === 1 ? '23' : '24';
                                        } else
                                        {
                                            $topic['code'] = '03';
                                        }
                                        break;
                                    case '正官':
                                        // 磨砺之运(运干为杀) 01 02
                                        // 执顽之运（运干为劫）25
                                        // 破立之运 06 07
                                        if ($yunGanShishen === '七杀')
                                        {
                                            $topic['code'] = $sex === 1 ? '01' : '02';
                                        } elseif ($yunGanShishen === '劫财')
                                        {
                                            $topic['code'] = '25';
                                        } else
                                        {
                                            $topic['code'] = $sex === 1 ? '06' : '07';
                                        }
                                        break;
                                    case '正印':
                                        // 风浪之运(运干为杀) 23 24
                                        // 思虑之运(运干为枭) 03
                                        // 执顽之运(运干为劫) 25
                                        if ($yunGanShishen === '七杀')
                                        {
                                            $topic['code'] = $sex === 1 ? '23' : '24';
                                        } elseif ($yunGanShishen === '偏印')
                                        {
                                            $topic['code'] = '03';
                                        } elseif ($yunGanShishen === '劫财')
                                        {
                                            $topic['code'] = '25';
                                        }
                                        break;
                                    case '正财':
                                        // 磨砺之运(运干为杀) 01 02
                                        // 破耗之运 18 19
                                        if ($yunGanShishen === '七杀')
                                        {
                                            $topic['code'] = $sex === 1 ? '01' : '02';
                                        } else
                                        {
                                            $topic['code'] = $sex === 1 ? '18' : '19';
                                        }
                                        break;
                                    case '偏财':
                                        // 磨砺之运(运干为杀) 01 02
                                        // 破耗之运 18 19
                                        if ($yunGanShishen === '七杀')
                                        {
                                            $topic['code'] = $sex === 1 ? '01' : '02';
                                        } else
                                        {
                                            $topic['code'] = $sex === 1 ? '18' : '19';
                                        }
                                        break;
                                }
                            }
                            if ($topic['code'] !== '')
                            {
                                break;
                            }
                        }
                    }
                } elseif (in_array($yunGanShishen, ['正财', '偏财', '正官', '正印', '食神'], true))
                {
                    switch ($yunGanShishen)
                    {
                        case '正财':
                            // 积富之运 26
                            $topic['code'] = '26';
                            break;
                        case '偏财':
                            // 飞财之运 20 21
                            $topic['code'] = $sex === 1 ? '20' : '21';
                            break;
                        case '正官':
                            // 名位之运 27 28
                            $topic['code'] = $sex === 1 ? '27' : '28';
                            break;
                        case '正印':
                            // 安恬之运 29
                            $topic['code'] = '29';
                            break;
                        case '食神':
                            // 欢愉之运 30
                            $topic['code'] = '30';
                            break;
                    }
                } elseif ($yunGanShishen === '比肩')
                {
                    if ($this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                    {
                        $topic['code'] = $sex === 1 ? '01' : '02';
                    } else
                    {
                        // 优先取健康值最小的
                        foreach ($jishenJiankangResortList as $k1 => $v1)
                        {
                            if ($topic['code'] === ''
                                && $this->zuhePanding(['type' => 0, 'xing1' => $v1['shishen'], 'xing2' => $jiDeKe[$v1['shishen']], 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                            {
                                switch ($v1['shishen'])
                                {
                                    case '食神':
                                        // 学思之运（用神+运干支枭）
                                        // 贪欢之运（用神+运干支食神）
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '偏印')
                                            {
                                                $topic['code'] = '04';
                                            } elseif ($yunGanShishen === '食神')
                                            {
                                                $topic['code'] = '05';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '偏印')
                                                {
                                                    $topic['code'] = '04';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '食神')
                                                {
                                                    $topic['code'] = '05';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = '03';
                                        }
                                        break;
                                    case '正官':
                                        // 破立之运 06 07
                                        // 求索之运（用神+运干支官）08 09
                                        // 变革之运（用神+运干支伤）10 11
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '正官')
                                            {
                                                $topic['code'] = $sex === 1 ? '08' : '09';
                                            } elseif ($yunGanShishen === '伤官')
                                            {
                                                $topic['code'] = $sex === 1 ? '10' : '11';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '正官')
                                                {
                                                    $topic['code'] = $sex === 1 ? '08' : '09';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '伤官')
                                                {
                                                    $topic['code'] = $sex === 1 ? '10' : '11';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = $sex === 1 ? '06' : '07';
                                        }
                                        break;
                                    case '正印':
                                        // 飘蓬之运 12
                                        // 依恋之运(用神+运干支印) 13
                                        // 辛勤之运(用神+运干支财) 14 15
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '正印')
                                            {
                                                $topic['code'] = '13';
                                            } elseif ($yunGanShishen === '正财')
                                            {
                                                $topic['code'] = $sex === 1 ? '14' : '15';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '正印')
                                                {
                                                    $topic['code'] = '13';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '正财')
                                                {
                                                    $topic['code'] = $sex === 1 ? '14' : '15';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = 12;
                                        }
                                        break;
                                    case '正财':
                                        // 破耗之运 18 19
                                        // 理财之运(用神+运干支劫) 16 17
                                        // 辛勤之运(用神+运干支财) 14 15
                                        if ($yongshen[$dayun[0]] > 0)
                                        {
                                            if ($yunGanShishen === '劫财')
                                            {
                                                $topic['code'] = $sex === 1 ? '16' : '17';
                                            } elseif ($yunGanShishen === '正财')
                                            {
                                                $topic['code'] = $sex === 1 ? '14' : '15';
                                            }
                                        } elseif ($yongshen[$dayun[1]] > 0)
                                        {
                                            foreach ($canggan[$dayun[1]] as $k2 => $v2)
                                            {
                                                if ($shishen[$v2][$tiangan[2]] === '劫财')
                                                {
                                                    $topic['code'] = $sex === 1 ? '16' : '17';
                                                    break;
                                                }

                                                if ($shishen[$v2][$tiangan[2]] === '正财')
                                                {
                                                    $topic['code'] = $sex === 1 ? '14' : '15';
                                                    break;
                                                }
                                            }
                                        } else
                                        {
                                            $topic['code'] = $sex === 1 ? '18' : '19';
                                        }
                                        break;
                                    case '偏财':
                                        // 飞财之运
                                        if ($yongshen[$piancaiGan] > 0)
                                        {
                                            $topic['code'] = $sex === 1 ? '20' : '21';
                                            break;
                                        }
                                        $topic['code'] = $sex === 1 ? '16' : '17';
                                        break;
                                }
                            }
                            if ($topic['code'] !== '')
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
        // 天干为吉受生组合
        if (
            $topic['code'] === '' &&
            ($this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])))
        {
            // 天干为吉受生组合且运干为
            $isDizhiJishengXiongzhi = false;
            // 地支有吉生凶制组合
            if ($this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '比肩', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '劫财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]]))
            {
                $isDizhiJishengXiongzhi = true;
            }
            switch ($yunGanShishen)
            {
                case '正官':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 通天之运(大运有用神，亲和等级1) 31
                        // 腾达之运(大运有用神，亲和等级2，或大运无用神，亲和1) 32 33
                        // 越进之运(有用神亲和3，无用神亲和2) 34 35
                        // 越进之运 34 35
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '31';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = $sex === 1 ? '32' : '33';
                            } elseif ($qinheLevel === 3)
                            {
                                $topic['code'] = $sex === 1 ? '34' : '35';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = $sex === 1 ? '32' : '33';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = $sex === 1 ? '34' : '35';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = $sex === 1 ? '34' : '35';
                        }
                    } else
                    {
                        // 腾达之运(大运有用神，亲和等级1) 32 33
                        // 越进之运(大运有用神，亲和等级2，或大运无用神，亲和1) 34 35
                        // 名位之运 27 28
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = $sex === 1 ? '32' : '33';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = $sex === 1 ? '34' : '35';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = $sex === 1 ? '34' : '35';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = $sex === 1 ? '27' : '28';
                        }
                    }
                    break;
                case '正财':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 聚宝之运(大运有用神，亲和等级1)  36
                        // 金玉之运(大运有用神，亲和等级2，或大运无用神，亲和1) 37
                        // 财福之运 38
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '36';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '37';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '37';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '38';
                        }
                    } else
                    {
                        // 金玉之运(大运有用神，亲和等级1) 37
                        // 财福之运(大运有用神，亲和等级2，或大运无用神，亲和1) 38
                        // 积富之运 26
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '37';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '38';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '38';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '26';
                        }
                    }
                    break;
                case '偏财':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 聚宝之运(大运有用神，亲和等级1) 36
                        // 金玉之运(大运有用神，亲和等级2，或大运无用神，亲和1) 37
                        // 财福之运 38
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '36';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '37';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '37';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '38';
                        }
                    } else
                    {
                        // 金玉之运(大运有用神，亲和等级1) 37
                        // 财福之运(大运有用神，亲和等级2，或大运无用神，亲和1) 38
                        // 飞财之运 20 21
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '37';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '38';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '38';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = $sex === 1 ? '20' : '21';
                        }
                    }
                    break;
                case '食神':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 华秀之运(大运有用神，亲和等级1) 39
                        // 长乐之运(大运有用神，亲和等级2，或大运无用神，亲和1) 40
                        // 无忧之运 41
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '39';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '40';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '40';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '41';
                        }
                    } else
                    {
                        // 长乐之运(大运有用神，亲和等级1) 40
                        // 无忧之运(大运有用神，亲和等级2，或大运无用神，亲和1) 41
                        // 欢愉之运 30
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '40';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '41';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '41';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '30';
                        }
                    }
                    break;
                case '正印':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 文昌之运(大运有用神，亲和等级1) 42
                        // 文华之运(大运有用神，亲和等级2，或大运无用神，亲和1) 43
                        // 治学之运 44
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '42';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '43';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '43';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '44';
                        }
                    } else
                    {
                        // 文华之运(大运有用神，亲和等级1) 43
                        // 治学之运(大运有用神，亲和等级2，或大运无用神，亲和1) 44
                        // 安恬之运 29
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '43';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '44';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '44';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '29';
                        }
                    }
                    break;
                case '七杀':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 英豪之运(杀为用) 45
                        // 奋进之运(杀不为用) 46 47
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = '45';
                        } else
                        {
                            $topic['code'] = $sex === 1 ? '46' : '47';
                        }
                    } else
                    {
                        // 奋进之运(杀为用) 46 47
                        // 攀山之运(杀不为用) 48
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = $sex === 1 ? '46' : '47';
                        } else
                        {
                            $topic['code'] = '48';
                        }
                    }
                    break;
                case '伤官':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 英华之运(伤为用) 49
                        // 开创之运(伤不为用) 50
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = '49';
                        } else
                        {
                            $topic['code'] = '50';
                        }
                    } else
                    {
                        // 开创之运(伤为用) 50
                        // 技艺之运(伤不为用) 51
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = '50';
                        } else
                        {
                            $topic['code'] = '51';
                        }
                    }
                    break;
                case '劫财':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 多助之运(劫为用) 52
                        // (劫不为用，地支本气为)
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = '52';
                        } else
                        {
                            switch ($yunBenqiShishen)
                            {
                                case '正官':
                                    // 官 名位 27 28
                                    $topic['code'] = $sex === 1 ? '27' : '28';
                                    break;
                                case '七杀':
                                    // 杀 奋进 46 47
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                    break;
                                case '正财':
                                    // 财 积富 26
                                    $topic['code'] = '26';
                                    break;
                                case '偏财':
                                    // 才 财福 38
                                    $topic['code'] = '38';
                                    break;
                                case '食神':
                                    // 食 欢愉 30
                                    $topic['code'] = '30';
                                    break;
                                case '伤官':
                                    // 伤 开创 50
                                    $topic['code'] = '50';
                                    break;
                                case '比肩':
                                    // 比 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '劫财':
                                    // 劫 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '正印':
                                    // 印 安恬 29
                                    $topic['code'] = '29';
                                    break;
                                case '偏印':
                                    // 枭 筹谋 55
                                    $topic['code'] = '55';
                                    break;
                            }
                        }
                    } else
                    {
                        // 得助之运(劫为用) 53
                        // (劫不为用，地支本气为)
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = '53';
                        } else
                        {
                            switch ($yunBenqiShishen)
                            {
                                case '正官':
                                    // 官 名位 27 28
                                    $topic['code'] = $sex === 1 ? '27' : '28';
                                    break;
                                case '七杀':
                                    // 杀 奋进 46 47
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                    break;
                                case '正财':
                                    // 财 破耗 18 19
                                    $topic['code'] = $sex === 1 ? '18' : '19';
                                    break;
                                case '偏财':
                                    // 才 飞财 20 21
                                    $topic['code'] = $sex === 1 ? '20' : '21';
                                    break;
                                case '食神':
                                    // 食 欢愉 30
                                    $topic['code'] = '30';
                                    break;
                                case '伤官':
                                    // 伤 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '比肩':
                                    // 比 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '劫财':
                                    // 劫 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '正印':
                                    // 印 安恬 29
                                    $topic['code'] = '29';
                                    break;
                                case '偏印':
                                    // 枭 思虑 03
                                    $topic['code'] = '03';
                                    break;
                            }
                        }
                    }
                    break;
                case '比肩':
                    if ($isDizhiJishengXiongzhi)
                    {
                        // 多助之运(比为用) 52
                        // (比不为用，地支本气为)
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = '52';
                        } else
                        {
                            switch ($yunBenqiShishen)
                            {
                                case '正官':
                                    // 官 名位 27 28
                                    $topic['code'] = $sex === 1 ? '27' : '28';
                                    break;
                                case '七杀':
                                    // 杀 奋进 46 47
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                    break;
                                case '正财':
                                    // 财 积富 26
                                    $topic['code'] = '26';
                                    break;
                                case '偏财':
                                    // 才 财福 38
                                    $topic['code'] = '38';
                                    break;
                                case '食神':
                                    // 食 欢愉 30
                                    $topic['code'] = '30';
                                    break;
                                case '伤官':
                                    // 伤 开创 50
                                    $topic['code'] = '50';
                                    break;
                                case '比肩':
                                    // 比 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '劫财':
                                    // 劫 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '正印':
                                    // 印 安恬 29
                                    $topic['code'] = '29';
                                    break;
                                case '偏印':
                                    // 枭 筹谋 55
                                    $topic['code'] = '55';
                                    break;
                            }
                        }
                    } else
                    {
                        // 得助之运(比为用) 53
                        // (比不为用，地支本气为)
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            $topic['code'] = '53';
                        } else
                        {
                            switch ($yunBenqiShishen)
                            {
                                case '正官':
                                    // 官 名位 27 28
                                    $topic['code'] = $sex === 1 ? '27' : '28';
                                    break;
                                case '七杀':
                                    // 杀 奋进 46 47
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                    break;
                                case '正财':
                                    // 财 破耗 18 19
                                    $topic['code'] = $sex === 1 ? '18' : '19';
                                    break;
                                case '偏财':
                                    // 才 飞财 20 21
                                    $topic['code'] = $sex === 1 ? '20' : '21';
                                    break;
                                case '食神':
                                    // 食 欢愉 30
                                    $topic['code'] = '30';
                                    break;
                                case '伤官':
                                    // 伤 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '比肩':
                                    // 比 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '劫财':
                                    // 劫 执顽 25
                                    $topic['code'] = '25';
                                    break;
                                case '正印':
                                    // 印 安恬 29
                                    $topic['code'] = '29';
                                    break;
                                case '偏印':
                                    // 枭 思虑 03
                                    $topic['code'] = '03';
                                    break;
                            }
                        }
                    }
                    break;
            }
        }
        // 天干为凶神受制组合
        if (
            $topic['code'] === '' &&
            ($this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
        )
        {
            $isDizhiJishengXiongzhi = false;
            // 地支有吉生凶制组合
            if ($this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '比肩', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '劫财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]]))
            {
                $isDizhiJishengXiongzhi = true;
            }
            // 天干为凶受制组合
            if ($this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
            {
                if ($isDizhiJishengXiongzhi)
                {
                    // 英豪之运(杀为用) 45
                    // 奋进之运(杀不为用) 46 47
                    if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                    {
                        $topic['code'] = '45';
                    } else
                    {
                        $topic['code'] = $sex === 1 ? '46' : '47';
                    }
                } else
                {
                    // 奋进之运(杀为用) 46 47
                    // 攀山之运(杀不为用) 48
                    if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                    {
                        $topic['code'] = $sex === 1 ? '46' : '47';
                    } else
                    {
                        $topic['code'] = '48';
                    }
                }
            } elseif ($this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
            {
                if ($yunGanShishen === '偏印')
                {
                    // 枭才
                    if ($this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        // 谋略之运（筹谋之运）
                        $topic['code'] = '55';
                    } else
                    {
                        if (in_array('伤官', $tiangan, true))
                        {
                            // 研学之运
                            $topic['code'] = '54';
                        } elseif (in_array('正财', $tiangan, true))
                        {
                            // 谋略之运（筹谋之运）
                            $topic['code'] = '55';
                        }
                    }
                } else
                {
                    if (in_array('伤官', $tiangan, true))
                    {
                        // 研学之运
                        $topic['code'] = '54';
                    } elseif (in_array('正财', $tiangan, true))
                    {
                        // 财福之运
                        $topic['code'] = '38';
                    } elseif (in_array('偏财', $tiangan, true))
                    {
                        // 财福之运
                        $topic['code'] = '38';
                    }
                }

            } elseif ($this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
            {
                // 凶为伤
                if ($yunGanShishen === '伤官')
                {
                    // 开创之运
                    $topic['code'] = '50';
                } else
                {
                    // 治学之运
                    $topic['code'] = '44';
                }
            } else
            {
                // 凶为劫
                if ($yunGanShishen === '劫财')
                {
                    // 劫官
                    if ($this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']]))
                    {
                        if (in_array('伤官', $tiangan, true))
                        {
                            // 执顽之运
                            $topic['code'] = '25';
                        } else
                        {
                            // 劫为用
                            if ($yongshen[$jiecaiGan] > 0)
                            {
                                switch ($yunBenqiShishen)
                                {
                                    case '正官':
                                        // 官 名位 27 28
                                        $topic['code'] = $sex === 1 ? '27' : '28';
                                        break;
                                    case '七杀':
                                        // 杀 奋进 46 47
                                        $topic['code'] = $sex === 1 ? '46' : '47';
                                        break;
                                    case '正财':
                                        // 财 积富 26
                                        $topic['code'] = '26';
                                        break;
                                    case '偏财':
                                        // 才 财福 38
                                        $topic['code'] = '38';
                                        break;
                                    case '食神':
                                        // 食 欢愉 30
                                        $topic['code'] = '30';
                                        break;
                                    case '伤官':
                                        // 伤 开创 50
                                        $topic['code'] = '50';
                                        break;
                                    case '比肩':
                                        // 比 执顽 25
                                        $topic['code'] = '25';
                                        break;
                                    case '劫财':
                                        // 劫 执顽 25
                                        $topic['code'] = '25';
                                        break;
                                    case '正印':
                                        // 印 安恬 29
                                        $topic['code'] = '29';
                                        break;
                                    case '偏印':
                                        // 枭 筹谋 55
                                        $topic['code'] = '55';
                                        break;
                                }
                            } else
                            {
                                // 劫不为用
                                switch ($yunBenqiShishen)
                                {
                                    case '正官':
                                        // 官 名位 27 28
                                        $topic['code'] = $sex === 1 ? '27' : '28';
                                        break;
                                    case '七杀':
                                        // 杀 奋进 46 47
                                        $topic['code'] = $sex === 1 ? '46' : '47';
                                        break;
                                    case '正财':
                                        // 财 破耗 18 19
                                        $topic['code'] = $sex === 1 ? '18' : '19';
                                        break;
                                    case '偏财':
                                        // 才 飞财 20 21
                                        $topic['code'] = $sex === 1 ? '20' : '21';
                                        break;
                                    case '食神':
                                        // 食 欢愉 30
                                        $topic['code'] = '30';
                                        break;
                                    case '伤官':
                                        // 伤 执顽 25
                                        $topic['code'] = '25';
                                        break;
                                    case '比肩':
                                        // 比 执顽 25
                                        $topic['code'] = '25';
                                        break;
                                    case '劫财':
                                        // 劫 执顽 25
                                        $topic['code'] = '25';
                                        break;
                                    case '正印':
                                        // 印 安恬 29
                                        $topic['code'] = '29';
                                        break;
                                    case '偏印':
                                        // 枭 思虑 03
                                        $topic['code'] = '03';
                                        break;
                                }
                            }
                        }
                    } else
                    {
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            // 飞财之运 20 21
                            $topic['code'] = '25';
                        } else
                        {
                            // 破耗之运 18 19
                            $topic['code'] = $sex === 1 ? '18' : '19';
                        }
                    }
                    // 开创之运
                    $topic['code'] = '50';
                } else
                {
                    if ($yunGanShishen === '偏财')
                    {
                        // 财福之运 38
                        $topic['code'] = '38';
                    } elseif ($yunGanShishen === '正官')
                    {
                        // 名位之运 27 28
                        $topic['code'] = $sex === 1 ? '27' : '28';
                    }

                }
            }
        }
        // 地支有吉受生
        if ($topic['code'] === '')
        {
            $isDizhiJishengXiongzhi = false;
            // 地支有吉生凶制组合
            if ($this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '比肩', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '劫财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]]))
            {
                $isDizhiJishengXiongzhi = true;
            }
            // 天干无组合，为吉
            if (in_array($yunGanShishen, ['正官', '正财', '偏财', '食神', '正印'], true))
            {
                switch ($yunGanShishen)
                {
                    case '正官':
                        // 腾达之运(大运有用神，亲和等级1) 32 33
                        // 越进之运(大运有用神，亲和等级2，或大运无用神，亲和1) 34 35
                        // 名位之运 27 28
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = $sex === 1 ? '32' : '33';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = $sex === 1 ? '34' : '35';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = $sex === 1 ? '34' : '35';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = $sex === 1 ? '27' : '28';
                        }
                        break;
                    case '正财':
                        // 金玉之运(大运有用神，亲和等级1) 37
                        // 财福之运(大运有用神，亲和等级2，或大运无用神，亲和1) 38
                        // 积富之运 26
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '37';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '38';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '38';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '26';
                        }
                        break;
                    case '偏财':
                        // 金玉之运(大运有用神，亲和等级1) 37
                        // 财福之运(大运有用神，亲和等级2，或大运无用神，亲和1) 38
                        // 飞财之运 20 21
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '37';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '38';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '38';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = $sex === 1 ? '20' : '21';
                        }
                        break;
                    case '食神':
                        // 长乐之运(大运有用神，亲和等级1) 40
                        // 无忧之运(大运有用神，亲和等级2，或大运无用神，亲和1) 41
                        // 欢愉之运 30
                        if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '40';
                            } elseif ($qinheLevel === 2)
                            {
                                $topic['code'] = '41';
                            }
                        } else
                        {
                            if ($qinheLevel === 1)
                            {
                                $topic['code'] = '41';
                            }
                        }
                        if ($topic['code'] === '')
                        {
                            $topic['code'] = '30';
                        }
                        break;
                    case '正印':
                        if ($isDizhiJishengXiongzhi)
                        {
                            // 文昌之运(大运有用神，亲和等级1) 42
                            // 文华之运(大运有用神，亲和等级2，或大运无用神，亲和1) 43
                            // 治学之运 44
                            if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                            {
                                if ($qinheLevel === 1)
                                {
                                    $topic['code'] = '42';
                                } elseif ($qinheLevel === 2)
                                {
                                    $topic['code'] = '43';
                                }
                            } else
                            {
                                if ($qinheLevel === 1)
                                {
                                    $topic['code'] = '43';
                                }
                            }
                            if ($topic['code'] === '')
                            {
                                $topic['code'] = '44';
                            }
                        } else
                        {
                            // 文华之运(大运有用神，亲和等级1) 43
                            // 治学之运(大运有用神，亲和等级2，或大运无用神，亲和1) 44
                            // 安恬之运 29
                            if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                            {
                                if ($qinheLevel === 1)
                                {
                                    $topic['code'] = '43';
                                } elseif ($qinheLevel === 2)
                                {
                                    $topic['code'] = '44';
                                }
                            } else
                            {
                                if ($qinheLevel === 1)
                                {
                                    $topic['code'] = '44';
                                }
                            }
                            if ($topic['code'] === '')
                            {
                                $topic['code'] = '29';
                            }
                        }
                        break;

                }
            }// 天干无组合，为凶
            elseif (in_array($yunGanShishen, ['七杀', '伤官', '偏印', '劫财'], true))
            {
                // 运干支为凶受制组合
                if ($this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun]))
                {
                    switch ($yunGanShishen)
                    {
                        case '七杀':
                            if ($isDizhiJishengXiongzhi)
                            {
                                // 英豪之运(杀为用) 45
                                // 奋进之运(杀不为用) 46 47
                                if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                                {
                                    $topic['code'] = '45';
                                } else
                                {
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                }
                            } else
                            {
                                // 奋进之运(杀为用) 46 47
                                // 攀山之运(杀不为用) 48
                                if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                                {
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                } else
                                {
                                    $topic['code'] = '48';
                                }
                            }
                            break;
                        case '伤官':
                            if (in_array($yunBenqiShishen, ['正印', '偏印'], true))
                            {
                                // 技艺之运 51
                                $topic['code'] = '51';
                            } elseif (in_array($yunBenqiShishen, ['正财', '偏财', '七杀'], true))
                            {
                                // 开创之运 50
                                $topic['code'] = '50';
                            }
                            break;
                        case '偏印':
                            if (in_array($yunBenqiShishen, ['正财', '偏财'], true))
                            {
                                // 谋略之运 55
                                $topic['code'] = '55';
                            } else
                            {
                                // 研学之运 54
                                $topic['code'] = '54';
                            }
                            break;
                        case '劫财':
                            if ($yunBenqiShishen === '偏财')
                            {
                                // 飞财之运 20 21
                                $topic['code'] = $sex === 1 ? '20' : '21';
                            } elseif ($yunBenqiShishen === '七杀')
                            {
                                // 奋进之运 46 47
                                $topic['code'] = $sex === 1 ? '46' : '47';
                            } elseif ($yunBenqiShishen === '正官')
                            {
                                // 得助之运 53
                                $topic['code'] = '53';
                            }
                            break;
                    }
                }
            } // 天干无组合，为比肩
            elseif ($yunGanShishen === '比肩')
            {
                // 运支本气为吉
                if (in_array($yunBenqiShishen, ['正官', '正财', '偏财', '食神', '正印'], true))
                {
                    switch ($yunGanShishen)
                    {
                        case '正财':
                            // 积富之运 26
                            $topic['code'] = '26';
                            break;
                        case '偏财':
                            // 飞财之运 20 21
                            $topic['code'] = $sex === 1 ? '20' : '21';
                            break;
                        case '正官':
                            // 名位之运 27 28
                            $topic['code'] = $sex === 1 ? '27' : '28';
                            break;
                        case '正印':
                            // 安恬之运 29
                            $topic['code'] = '29';
                            break;
                        case '食神':
                            // 欢愉之运 30
                            $topic['code'] = '30';
                            break;
                    }
                }// 运支本气为凶
                elseif (in_array($yunBenqiShishen, ['七杀', '伤官', '偏印', '劫财'], true))
                {
                    switch ($yunGanShishen)
                    {
                        case '七杀':
                            if ($isDizhiJishengXiongzhi)
                            {
                                // 英豪之运(杀为用) 45
                                // 奋进之运(杀不为用) 46 47
                                if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                                {
                                    $topic['code'] = '45';
                                } else
                                {
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                }
                            } else
                            {
                                // 奋进之运(杀为用) 46 47
                                // 攀山之运(杀不为用) 48
                                if ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                                {
                                    $topic['code'] = $sex === 1 ? '46' : '47';
                                } else
                                {
                                    $topic['code'] = '48';
                                }
                            }
                            break;
                        case '伤官':
                            if (in_array($yunBenqiShishen, ['正印', '偏印'], true))
                            {
                                // 技艺之运 51
                                $topic['code'] = '51';
                            } elseif (in_array($yunBenqiShishen, ['正财', '偏财', '七杀'], true))
                            {
                                // 开创之运 50
                                $topic['code'] = '50';
                            }
                            break;
                        case '偏印':
                            if (in_array($yunBenqiShishen, ['正财', '偏财'], true))
                            {
                                // 谋略之运 55
                                $topic['code'] = '55';
                            } else
                            {
                                // 研学之运 54
                                $topic['code'] = '54';
                            }
                            break;
                        case '劫财':
                            if ($yunBenqiShishen === '偏财')
                            {
                                // 飞财之运 20 21
                                $topic['code'] = $sex === 1 ? '20' : '21';
                            } elseif ($yunBenqiShishen === '七杀')
                            {
                                // 奋进之运 46 47
                                $topic['code'] = $sex === 1 ? '46' : '47';
                            } elseif ($yunBenqiShishen === '正官')
                            {
                                // 得助之运 53
                                $topic['code'] = '53';
                            }
                            break;
                    }
                }
            }
        }

        if ($topic['code'] === '')
        {
            // 无常之运
            $topic['code'] = '56';
        }

        foreach ($this->bazi['dayun'] as $k1 => $v1)
        {
            // 进行中的大运 [-1已过去｜0进行中｜1未开始]
            if ($this->advance['year'] >= $v1['start_year'] && $this->advance['year'] <= $v1['end_year'])
            {
                $topic['index'] = $k1 + 1;
                $topic['start'] = $v1['start_year'];
                $topic['end'] = $v1['end_year'];
                break;
            }
        }

        $yearsOld = $topic['start'] - $this->record['year'];

        /**
         * 婚恋
         */
        $hunNum = 0;
        /**
         * 姻缘天成
         *  佳运，可成婚
         *  成婚概率极大（如已成婚则感情极好），且很可能拥有一份稳定的恋情，有情人相知相守，天长地久不是梦，少数流年可能会有沟通或距离问题，但即便有一点阻碍也能克服。
         *  夫妻星、夫妻宫、印星动态均不低于1，且亲和不高于3级，且夫妻星健康值大于0 (印星使用动态值)
         */
        if ($hunNum === 0)
        {
            if ($zhuti['hunlian']['gong_dongtai'] >= 1
                && $zhuti['hunlian']['xing_dongtai'] >= 1
                && $yinDongying >= 1 && $qinheLevel >= 1 && $qinheLevel <= 3
                && $jiankang[$fuqiGan1]['jiankang'] > 0
                && $jiankang[$fuqiGan2]['jiankang'] > 0)
            {
                $texts[] = '0101';
                $hunNum++;
            }
        }
        /**
         * 执子之手
         *  可成婚
         *  有成婚的可能性（如已成婚则利于感情稳定），你会收获一份稳定有保障的感情，少数情况下会跟年龄偏大的人在一起。
         *  夫妻星、夫妻宫、印星动态均不低于1，且夫妻星健康值大于0
         */
        if ($hunNum === 0)
        {
            if ($zhuti['hunlian']['gong_dongtai'] >= 1
                && $zhuti['hunlian']['xing_dongtai'] >= 1
                && $yinDongying >= 1
                && $jiankang[$fuqiGan1]['jiankang'] > 0
                && $jiankang[$fuqiGan2]['jiankang'] > 0)
            {
                $texts[] = '0102';
                $hunNum++;
            }
        }
        /**
         * 锦绣风华
         *  桃花旺
         *  你会得到很多的爱，或许是你魅力出众赢得很多人喜欢，或许是喜欢你的人对你痴迷情深，总之这是深情绻缱之时，再没有比这更适合恋爱的运势
         *  夫妻星，夫妻宫动态均不低于1，且亲和不高于3级
         */
        if ($hunNum === 0)
        {
            if ($zhuti['hunlian']['gong_dongtai'] >= 1
                && $zhuti['hunlian']['xing_dongtai'] >= 1 && $qinheLevel <= 3)
            {
                $texts[] = '0103';
                $hunNum++;
            }
        }
        /**
         * 独自美丽
         *  无桃花
         *  桃花不算很旺，如已成婚则婚姻稳定，如未婚恋，可能大多时候是一个人生活，或许你并无太多婚恋需求，一个人的日子过得舒适开心，好的缘分若还没来敲门，当然不能随便凑合，一个人的潇洒，绝好过两个人的纠缠。
         *  婚恋动态为零或本命大运均无夫妻星
         */
        if ($hunNum === 0)
        {
            if (($zhuti['hunlian']['gong_dongtai'] === 0 && $zhuti['hunlian']['xing_dongtai'] === 0))
            {
                $texts[] = '0104';
                $hunNum++;
            } elseif ((!in_array($fuqiGan1, $allTiangan, true) && !in_array($fuqiGan2, $allTiangan, true)))
            {
                $youFuqiXing = false;
                foreach ($allDizhi as $k1 => $v1)
                {
                    foreach ($canggan[$v1] as $k2 => $v2)
                    {
                        if (in_array($v2, [$fuqiGan1, $fuqiGan2], true))
                        {
                            $youFuqiXing = true;
                            break 2;
                        }
                    }
                }
                if (!$youFuqiXing)
                {
                    $texts[] = '0104';
                    $hunNum++;
                }
            }
        }
        /**
         * 小荷初露
         *  情窦初开
         *  花季雨季，情窦初开。这个世界因爱而生动美丽，虽然稚嫩的感情一经风雨很容易摧折，但最美的年龄最心跳的爱情，永远值得期许。
         *  仅限第一步运，且运势截止年龄不低于16，不高于20；夫妻星、夫妻宫动态均大于1
         */
        if ($hunNum === 0)
        {
            if ($this->advance['year'] >= $this->bazi['dayun'][0]['start_year']
                && $this->advance['year'] <= $this->bazi['dayun'][0]['end_year']
                && $this->bazi['dayun'][0]['end_year'] - $this->record['year'] >= 16
                && $this->bazi['dayun'][0]['end_year'] - $this->record['year'] <= 20
                && $zhuti['hunlian']['gong_dongtai'] > 1 && $zhuti['hunlian']['xing_dongtai'] > 1)
            {
                $texts[] = '0105';
                $hunNum++;
            }
        }
        /**
         * 繁花过眼
         * 桃花不稳定
         * 夫妻星与夫妻宫动态均大于1，其一负面大于零，夫妻星健康值低于0.5或存在食杀、官伤组合
         */
        if ($hunNum === 0)
        {
            if ($zhuti['hunlian']['gong_dongtai'] > 1 && $zhuti['hunlian']['xing_dongtai'] > 1 && ($zhuti['hunlian']['gong_fumian'] > 0 || $zhuti['hunlian']['xing_fumian'] > 0)
                && (($jiankang[$fuqiGan1]['jiankang'] < 0.5
                        && $jiankang[$fuqiGan2]['jiankang'] < 0.5)
                    || $this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
            {
                $texts[] = '0106';
                $hunNum++;
            }
        }
        /**
         * 红拂夜奔
         *  胆大，不拘
         *  1、女，原局印星健康小于0.5或综实小于20，财星或食伤综实大于【40】，大运夫妻星、夫妻宫动态均大于0，其一负面大于0
         *  2、女，原局食伤综实大于【30】，官杀综实大于【30】，存在枭神夺食，伤官或劫财透干，运支本气为财，大运夫妻动态大于1
         */
        if ($hunNum === 0)
        {
            $x1_7_1 = $x1_7_2 = $x1_7_3 = false;
            if ($jiankang[$zhengyinGan]['jiankang'] < 0.5 || $jiankang[$zhengyinGan]['zong_shili'] < 20)
            {
                $x1_7_1 = true;
            }
            if ($jiankang[$zhengcaiGan]['zong_shili'] > 40
                || $jiankang[$piancaiGan]['zong_shili'] > 40
                || $jiankang[$shishenGan]['zong_shili'] > 40
                || $jiankang[$shangguanGan]['zong_shili'] > 40)
            {
                $x1_7_2 = true;
            }
            if ($zhuti['hunlian']['gong_dongtai'] > 0 && $zhuti['hunlian']['xing_dongtai'] > 0 && ($zhuti['hunlian']['gong_fumian'] > 0 || $zhuti['hunlian']['gong_fumian'] > 0))
            {
                $x1_7_3 = true;
            }
            if ($x1_7_1 && $x1_7_2 && $x1_7_3)
            {
                $texts[] = '0107';
                $hunNum++;
            }
        }
        if ($hunNum === 0)
        {
            $x1_7_1 = $x1_7_2 = $x1_7_3 = $x1_7_4 = $x1_7_5 = $x1_7_6 = false;
            if ($jiankang[$shishenGan]['zong_shili'] > 30 || $jiankang[$shangguanGan]['zong_shili'] > 30)
            {
                $x1_7_1 = true;
            }
            if ($jiankang[$zhengguanGan]['zong_shili'] > 30 || $jiankang[$qishaGan]['zong_shili'] > 30)
            {
                $x1_7_2 = true;
            }
            // 枭神夺食
            if ($this->zuhePanding(['type' => 0, 'xing1' => '偏印', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
            {
                $x1_7_3 = true;
            }
            if (in_array($shangguanGan, $tiangan, true) || in_array($jiecaiGan, $tiangan, true))
            {
                $x1_7_4 = true;
            }
            if ($yunBenqiShishen === '正财')
            {
                $x1_7_5 = true;
            }
            if ($zhuti['hunlian'] > 1)
            {
                $x1_7_6 = true;
            }
            if ($x1_7_1 && $x1_7_2 && $x1_7_3 && $x1_7_4 && $x1_7_5 && $x1_7_6)
            {
                $texts[] = '0107';
                $hunNum++;
            }
        }
        /**
         * 春风十里 0108
         * （起运不低于16，不高于60岁）婚恋动态大于0，无负面值，大运干或支与原局合（干合，支合，暗合）
         */
        if ($hunNum === 0 && $yearsOld >= 16 && $yearsOld <= 60)
        {
            if (($zhuti['hunlian']['gong_dongtai'] > 0 || $zhuti['hunlian']['xing_dongtai'] > 0) && $zhuti['hunlian']['gong_fumian'] <= 0 && $zhuti['hunlian']['xing_fumian'] <= 0)
            {
                $x_1_8_1 = false;
                foreach ($tiangan as $k1 => $v1)
                {
                    if ($this->horoscopeInstance->is_wuhe($v1, $dayun[0]))
                    {
                        $x_1_8_1 = true;
                        break;
                    }
                }
                if (!$x_1_8_1)
                {
                    foreach ($dizhi as $k1 => $v1)
                    {
                        if ($this->horoscopeInstance->is_liuhe($dayun[1], $v1) || $this->horoscopeInstance->is_anhe($dayun[1], $v1))
                        {
                            $x_1_8_1 = true;
                            break;
                        }
                    }
                }
                if ($x_1_8_1)
                {
                    $texts[] = '0108';
                    $hunNum++;
                }
            }
        }
        /**
         * 花落花开 0109
         *  （起运不低于16）大运冲夫妻宫
         *   大运干支本气有伤官或劫财，且运支刑冲穿原局，无合日时干支
         */
        if ($hunNum === 0 && $yearsOld >= 16)
        {
            $x0109 = false;
            if ($this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[2]))
            {
                $x0109 = true;
            }
            if ($x0109 === false
                && (in_array($yunGanShishen, ['伤官', '劫财'], true) || in_array($yunBenqiShishen, ['伤官', '劫财'], true)))
            {
                $isXCC = false;
                foreach ($dizhi as $k1 => $v1)
                {
                    if ($this->horoscopeInstance->is_xing($dayun[1], $v1)
                        || $this->horoscopeInstance->is_liuchong($dayun[1], $v1)
                        || $this->horoscopeInstance->is_liuhai($dayun[1], $v1))
                    {
                        $isXCC = true;
                    }
                }
                $isHeRiShiGZ = false;
                if ($this->horoscopeInstance->is_wuhe($dayun[0], $tiangan[2])
                    || $this->horoscopeInstance->is_wuhe($dayun[0], $tiangan[3])
                    || $this->horoscopeInstance->is_wuhe($dayun[1], $dizhi[2])
                    || $this->horoscopeInstance->is_wuhe($dayun[1], $dizhi[3])
                )
                {
                    $isHeRiShiGZ = true;
                }
                if ($isXCC && !$isHeRiShiGZ)
                {
                    $x0109 = true;
                }
            }
            if ($x0109)
            {
                $texts[] = '0109';
                $hunNum++;
            }
        }
        /**
         * 踏雪寻香 0110
         *  婚恋有动态值，天干或者地支（或大运干支本气之间）有吉受克组合，或运干支本气有食神伤官（女）比肩劫财（男）
         */
        if ($hunNum === 0)
        {
            $x0110 = false;
            if ($zhuti['hunlian']['gong_dongtai'] > 0 || $zhuti['hunlian']['xing_dongtai'] > 0)
            {
                if (($sex === 1
                        && (in_array($yunGanShishen, ['比肩', '劫财'], true)
                            || in_array($yunBenqiShishen, ['比肩', '劫财'], true)))
                    || ($sex === 2
                        && (in_array($yunGanShishen, ['食神', '伤官'], true)
                            || in_array($yunBenqiShishen, ['食神', '伤官'], true))))
                {
                    $x0110 = true;
                }
                if (!$x0110
                    && (
                        $this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => [], 'yun' => [$dayun[0], '']])

                        || $this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => [], 'dizhi' => $dizhi, 'yun' => ['', $dayun[1]]])

                        || $this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                        || $this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => [], 'dizhi' => [], 'yun' => $dayun])
                    )
                )
                {
                    $x0110 = true;
                }
            }
            if ($x0110)
            {
                $texts[] = '0110';
                $hunNum++;
            }
        }
        /**
         * 喜鹊双飞 0111
         *  婚恋有动态值，天干地支均无吉受克组合
         */
        if ($hunNum === 0)
        {
            if ($zhuti['hunlian']['gong_dongtai'] > 0 || $zhuti['hunlian']['xing_dongtai'] > 0)
            {
                if (!$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $texts[] = '0111';
                    $hunNum++;
                }
            }
        }
        /**
         * 灯火阑珊 0112
         *  （起运不高于40）无其他婚恋词条
         */
        if ($hunNum === 0 && $yearsOld <= 40)
        {
            $texts[] = '0112';
            $hunNum++;
        }

        /**
         * 财富
         * 堆金积玉
         *  发财
         *  财星健康大于0.5，动应大于0.5，大运亲和度高于3，大运干支都是用神，本命有财库或财星本气地支
         */
        $caiNum = 0;
        $caiDongying1 = $this->dongyingScore('正财', 1, $dayun);
        $caiDongying2 = $this->dongyingScore('偏财', 1, $dayun);
        if ($caiNum === 0)
        {
            if ($jiankang[$zhengcaiGan]['jiankang'] > 0.5 && $jiankang[$piancaiGan]['jiankang'] > 0.5
                && ($caiDongying1 > 0.5 || $caiDongying2 > 0.5)
                && $qinheLevel > 3 && $yongshen[$dayun[0]] > 0 && $yongshen[$dayun[1]])
            {
                // 本命有财库或财星本气地支 $muKu
                if (in_array($this->muKu[$zhengcaiGan], $dizhi, true)
                    || in_array($this->muKu[$piancaiGan], $dizhi, true)
                    || $canggan[$dizhi[0]][0] === $zhengcaiGan
                    || $canggan[$dizhi[0]][0] === $piancaiGan
                    || $canggan[$dizhi[1]][0] === $zhengcaiGan
                    || $canggan[$dizhi[1]][0] === $piancaiGan
                    || $canggan[$dizhi[2]][0] === $zhengcaiGan
                    || $canggan[$dizhi[2]][0] === $piancaiGan
                    || $canggan[$dizhi[3]][0] === $zhengcaiGan
                    || $canggan[$dizhi[3]][0] === $piancaiGan)
                {
                    $texts[] = '0201';
                    $caiNum++;
                }
            }
        }
        /**
         * 丰衣足食
         *  发小财
         *  财星健康大于0.5，动应不为零，不存在财劫组合，大运干支有用神
         */
        if ($caiNum === 0)
        {
            if ($jiankang[$zhengcaiGan]['jiankang'] > 0.5 && $jiankang[$piancaiGan]['jiankang'] > 0.5
                && ($caiDongying1 !== 0 || $caiDongying2 !== 0)
                && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0))
            {
                $texts[] = '0202';
                $caiNum++;
            }
        }
        /**
         * 流水绵长
         *  稳定入账
         *  财星健康大于0.5，不存在财劫、官伤组合，大运支不与原局成冲穿刑
         */
        if ($caiNum === 0)
        {
            if ($jiankang[$zhengcaiGan]['jiankang'] > 0.5 && $jiankang[$piancaiGan]['jiankang'] > 0.5
                && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
            {
                $isCCX = false;
                foreach ($dizhi as $k1 => $v1)
                {
                    if ($k1 < 4)
                    {
                        if ($this->horoscopeInstance->is_liuchong($v1, $dayun[1])
                            || $this->horoscopeInstance->is_liuhai($v1, $dayun[1])
                            || $this->horoscopeInstance->is_xing($v1, $dayun[1]))
                        {
                            $isCCX = true;
                            break;
                        }
                    }
                }
                if (!$isCCX)
                {
                    $texts[] = '0203';
                    $caiNum++;
                }
            }
        }
        /**
         * 天降横财
         *  横财，进出
         *  原局偏财星有库或本气地支或透干，同时有劫财透干或地支本气，大运天干或地支本气为偏财或 大运天干或地支本气为劫印且与原局偏财有干合、支合、支拱关系，大运有用神
         */
        if ($caiNum === 0)
        {
            // 大运有用神 大运天干或地支本气为偏财
            if ((in_array($this->muKu[$piancaiGan], $dizhi, true)
                    || in_array($piancaiGan, $tiangan, true)
                    || in_array($piancaiGan, $dizhiBenqiList, true))
                && (in_array($jiecaiGan, $tiangan, true)
                    || in_array($jiecaiGan, $dizhiBenqiList, true))
                && ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
            )
            {
                if ($yunGanShishen === '偏财' || $yunBenqiShishen === '偏财')
                {
                    $texts[] = '0204';
                    $caiNum++;
                } else
                {
                    $x2_4_1 = false;
                    // 与原局偏财有干合、支合、支拱关系
                    if (in_array($piancaiGan, $dizhiBenqiList, true))
                    {
                        foreach ($dizhiBenqiList as $k1 => $v1)
                        {
                            if ($piancaiGan === $v1 && ($this->horoscopeInstance->is_liuhe($dayun[1], $dizhi[$k1])
                                    || $this->horoscopeInstance->is_gong($dayun[1], $dizhi[$k1])))
                            {
                                $x2_4_1 = true;
                                break;
                            }
                        }
                    }
                    if ($x2_4_1
                        && (($yunGanShishen === '劫财' || $yunBenqiShishen === '劫财')
                            || ($yunGanShishen === '正印' || $yunBenqiShishen === '正印'))
                        && in_array($piancaiGan, $tiangan, true)
                        && $this->horoscopeInstance->is_wuhe($dayun[0], $piancaiGan))
                    {
                        $texts[] = '0204';
                        $caiNum++;
                    }
                }
            }
        }
        /**
         * 出入回环
         *  散财，进进出出
         *  财星健康小于0.5，比劫动应大于零
         */
        $biDongying = $this->dongyingScore('比肩', 1, $dayun);
        $jieDongying = $this->dongyingScore('劫财', 1, $dayun);
        if ($caiNum === 0)
        {
            if ($jiankang[$zhengcaiGan]['jiankang'] < 0.5 && $biDongying > 0 && $jieDongying > 0)
            {
                $texts[] = '0205';
                $caiNum++;
            }
        }

        /**
         * 事业（仅限起点16-55岁的运势）
         */
        $shiyeText = '';
        if ($yearsOld >= 16 && $yearsOld <= 55)
        {
            /**
             * 鱼跃成龙 0301 （此处还需要排查前面的大运结果是否有鱼跃成龙）
             *  大运干支有用神，大运亲和不高于3，官杀动应大于零，官健康大于0.5，大运干支都带吉受生、凶受制的组合，且无吉受克组合（前面几步运均非鱼跃成龙，如前运有鱼跃成龙，此运改为 飞龙在天）
             * 飞龙在天 0302
             *  同上
             */
            $shiNum = 0;
            $guanDongying = $this->dongyingScore('正官', 1, $dayun);
            $shaDongying = $this->dongyingScore('七杀', 1, $dayun);
            if ($shiNum === 0)
            {
                $dayunList = array_slice($this->bazi['dayun'], 0, $topic['index']);
                $passNum = 0;
                $isLastPass = false;
                foreach ($dayunList as $k1 => $v1)
                {
                    $dayunTmp = [mb_substr($v1['name'], 0, 1), mb_substr($v1['name'], 1, 1)];
                    if (($yongshen[$dayunTmp[0]] > 0 || $yongshen[$dayunTmp[1]] > 0)
                        && $qinheLevel >= 1 && $qinheLevel <= 3 && $guanDongying > 0 && $shaDongying > 0 && $jiankang[$zhengguanGan]['jiankang'] > 0.5)
                    {
                        // 大运干支都带吉受生、凶受制的组合，且无吉受克组合
                        /**
                         * 0吉受克组合 财+劫，才+比，官+伤，食+枭，印+财，杀+日干，杀+同性根，杀+禄
                         * 1吉受生组合 财+食，财+伤，才+食，才+伤，官+财，官+才，食+比，食+劫，印+官，印+杀
                         * 2凶受制组合
                         *   1类：伤+印，劫+官，杀+食，枭+才
                         *   2类：伤+合干，劫+杀合，杀+合干，枭+合干
                         *   3类：伤+财，伤+才，劫+食，杀+印
                         */
                        if (!$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            && (
                                $this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '正财', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '食神', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            )
                            && (
                                $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                                || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayunTmp])
                            )
                        )
                        {
                            $passNum++;
                            if ($k1 === $topic['index'] - 1) $isLastPass = true;
                        }

                    }
                }
                if ($passNum === 1 && $isLastPass)
                {
                    $texts[] = '0301';
                    $shiNum++;
                    $shiyeText = '0301';
                } elseif ($passNum > 1)
                {
                    $texts[] = '0302';
                    $shiNum++;
                    $shiyeText = '0302';
                }
            }
            /**
             * 浪里行船 0303
             *  大运干支本气有杀伤枭劫之一，且运支与原局日月时或日干的同性根有对冲，大运干支有用神
             */
            if ($shiNum === 0)
            {
                if (($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                    && (in_array($yunGanShishen, ['七杀', '伤官', '偏印', '劫财'], true)
                        || in_array($yunBenqiShishen, ['七杀', '伤官', '偏印', '劫财'], true)))
                {
                    // 运支与原局日月时或日干的同性根有对冲
                    foreach ($dizhi as $k1 => $v1)
                    {
                        if ($this->horoscopeInstance->is_liuchong($dayun[1], $v1)
                            && (in_array($k1, [1, 2, 3], true)
                                || in_array($tiangan[2], $canggan[$v1], true)))
                        {
                            $texts[] = '0303';
                            $shiNum++;
                            $shiyeText = '0303';
                        }
                    }
                }
            }
            /**
             * 攀山跨海 0304
             *  大运干或支本气为七杀，或，本命七杀综实大于40而大运干支本气见印劫食（见食神不同时见枭），大运有用神
             */
            if ($shiNum === 0)
            {
                if (($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0))
                {
                    if (($yunGanShishen === '七杀' || $yunBenqiShishen === '七杀')
                        || (
                            $jiankang[$qishaGan]['zong_shili'] > 40
                            && (in_array($yunGanShishen, ['正印', '劫财', '食神'])
                                || in_array($yunBenqiShishen, ['正印', '劫财', '食神']))
                            && !$this->zuhePanding(['type' => 0, 'xing1' => '偏印', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                    {
                        $texts[] = '0304';
                        $shiNum++;
                        $shiyeText = '0304';
                    }
                }
            }
            /**
             * 稳如泰山 0305
             *  大运干支本气均为财才官印食比，且无吉受克组合，大运不与原局刑冲穿
             */
            if ($shiNum === 0)
            {
                if (in_array($yunGanShishen, ['正财', '偏财', '正官', '正印', '食神', '比肩'], true)
                    && in_array($yunBenqiShishen, ['正财', '偏财', '正官', '正印', '食神', '比肩'], true))
                {
                    $x3_4_1 = true;
                    foreach ($dizhi as $k1 => $v1)
                    {
                        if ($this->horoscopeInstance->is_xing($v1, $dayun[1])
                            || $this->horoscopeInstance->is_liuchong($v1, $dayun[1])
                            || $this->horoscopeInstance->is_liuhai($v1, $dayun[1]))
                        {
                            $x3_4_1 = false;
                            break;
                        }
                    }
                    // 且无吉受克组合
                    if ($x3_4_1
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                    {
                        $texts[] = '0305';
                        $shiNum++;
                        $shiyeText = '0305';
                    }
                }
            }
            /**
             * 待时而飞 0306
             *  大运干支本气有官杀，有杀时本命干支本气有劫印食伤之一且健康值大于0.5；或，本命官杀旺度超过40。不满足以上各词条。
             */
            if ($shiNum === 0)
            {
                $x3_5_1 = false;
                if ((in_array($yunGanShishen, ['正官', '七杀'], true) || in_array($yunBenqiShishen, ['正官', '七杀'], true)))
                {
                    if ($yunGanShishen === '七杀' || $yunBenqiShishen === '七杀')
                    {
                        foreach ($tiangan as $k1 => $v1)
                        {
                            if ($k1 === 2) continue;
                            if ($jiankang[$v1]['jiankang'] > 0.5
                                && in_array($shishen[$v1][$tiangan[2]], ['劫财', '正印', '食神', '伤官'], true))
                            {
                                $x3_5_1 = true;
                            }
                        }
                        if ($x3_5_1 === false)
                        {
                            foreach ($dizhi as $k1 => $v1)
                            {
                                if ($jiankang[$canggan[$v1][0]]['jiankang'] > 0.5
                                    && in_array($shishen[$canggan[$v1][0]][$tiangan[2]], ['劫财', '正印', '食神', '伤官'], true))
                                {
                                    $x3_5_1 = true;
                                }
                            }
                        }
                    }
                }
                if ($x3_5_1 === false)
                {
                    $guanwang = $jiankang[$zhengguanGan]['shili'];
                    $shawang = $jiankang[$shangguanGan]['shili'];
                    if ($guanwang > 40 && $shawang > 40)
                    {
                        $x3_5_1 = true;
                    }
                }
                if ($x3_5_1)
                {
                    $texts[] = '0306';
                    $shiNum++;
                    $shiyeText = '0306';
                }
            }
            /**
             * 天高海阔 0307
             *  大运天干或地支本气为伤官
             */
            if ($shiNum === 0)
            {
                if ($yunGanShishen === '伤官' || $yunBenqiShishen === '伤官')
                {
                    $texts[] = '0307';
                    $shiNum++;
                    $shiyeText = '0307';
                }
            }
            /**
             * 步步为营 0309
             *  大运有吉受生或凶受制组合 // ，如有吉受克则受克吉神健康不低于0.6
             */
            if ($shiNum === 0)
            {
                if ($this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '偏财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '比肩', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '杀合', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '合干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '伤官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '劫财', 'xing2' => '食神', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                {
                    $texts[] = '0309';
                    $shiNum++;
                    $shiyeText = '0309';
                }
            }
            /**
             * 曲径通幽 0308
             * 普通
             * 不满足以上各词条
             */
            if ($shiNum === 0)
            {
                $texts[] = '0308';
                $shiNum++;
                $shiyeText = '0308';
            }
        }

        /**
         * 沙里淘金-财富 0206
         *  普通
         *  其它配置
         */
        if ($caiNum === 0)
        {
            // 如果事业是鱼跃成龙或飞龙在天 变为丰衣足食
            if ($shiyeText === '0301' || $shiyeText === '0302')
            {
                $texts[] = '0202';
            } // 如果事业是浪里行船或者攀山跨海 变为 起伏不定
            elseif ($shiyeText === '0303' || $shiyeText === '0304')
            {
                $texts[] = '0207';
            }// 如果事业是稳如泰山 变为流水绵长
            elseif ($shiyeText === '0305')
            {
                $texts[] = '0207';
            } else
            {
                $texts[] = '0206';
            }
            $caiNum++;
        }

        // 求学（仅限1-4步运）
        if ($topic['index'] >= 1 && $topic['index'] <= 4)
        {
            /**
             * 金榜题名 0401
             *  原局有正印或偏印本气支或透干，且正偏印健康均不小于0.5，大运干支本气不是财才，不见财星与印枭正克、冲组合，大运无吉受克组合，有官或印受生组合或大运见印枭
             *  TODO 附加条件：星盘本命3/9宫内不可见土星参与的刑冲相
             */
            $qiuxueNum = 0;
            if ($qiuxueNum === 0)
            {
                $x4_1_1 = false;
                foreach ($tiangan as $k1 => $v1)
                {
                    if ($k1 === 2) continue;
                    if ($jiankang[$v1]['jiankang'] >= 0.5 && in_array($shishen[$v1][$tiangan[2]], ['正印', '偏印'], true))
                    {
                        $x4_1_1 = true;
                        break;
                    }
                }
                if ($x4_1_1 === false)
                {
                    foreach ($dizhi as $k1 => $v1)
                    {
                        if ($jiankang[$canggan[$v1][0]]['jiankang'] >= 0.5 && in_array($shishen[$canggan[$v1][0]][$tiangan[2]], ['正印', '偏印'], true))
                        {
                            $x4_1_1 = true;
                            break;
                        }
                    }
                }
                if ($x4_1_1)
                {
                    // 大运干支本气不是财才 ，不见财星与印枭正克、冲组合，大运无吉受克组合，有官或印受生组合或大运见印枭
                    // 吉受克组合 财+劫，才+比，官+伤，食+枭，印+财，杀+日干，杀+同性根，杀+禄
                    // 吉受生组合 财+食，财+伤，才+食，才+伤，官+财，官+才，食+比，食+劫，印+官，印+杀
                    if (!in_array($yunGanShishen, ['正财', '偏财'], true) && !in_array($yunBenqiShishen, ['正财', '偏财'], true)
//                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 2, 'xing1' => '偏印', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && (in_array($yunGanShishen, ['正印', '偏印'], true)
                            || in_array($yunBenqiShishen, ['正印', '偏印'], true)
                            || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                            || $this->zuhePanding(['type' => 1, 'xing1' => '正官', 'xing2' => '偏财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                            || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                            || $this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                    {
                        $texts[] = '0401';
                        $qiuxueNum++;
                    }
                }
            }
            /**
             * 书山有路 0402
             *  非金榜题名，大运干支本气是枭印，枭不是忌状态，印不见受克组合；或，大运干支本气有官杀，杀不是忌状态，官不见受克组合
             */
            if ($qiuxueNum === 0)
            {
                if (($this->isXiongshenJi(1, ['偏印'], $dayun)
                        && (in_array($yunGanShishen, ['正印', '偏印'], true)
                            || (in_array($yunBenqiShishen, ['正印', '偏印'], true)))
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
                    || ($this->isXiongshenJi(1, ['七杀'], $dayun)
                        && (in_array($yunGanShishen, ['正官', '七杀'], true)
                            || (in_array($yunBenqiShishen, ['正官', '七杀'], true)))
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $texts[] = '0402';
                    $qiuxueNum++;
                }
            }
            /**
             * 明珠生尘 0403
             *  仅限起点在18岁以前的运势：本命印星健康均小于0.5，印星综实均小于25，大运非“干支本气有印星且运支拱合本命日支”；大运有杀伤枭劫的忌状态，无印受生组合
             */
            if ($yearsOld < 18 && $qiuxueNum === 0)
            {
                if ($jiankang[$zhengyinGan]['jiankang'] < 0.5 && $jiankang[$pianyinGan]['jiankang'] < 0.5
                    && $jiankang[$zhengyinGan]['zong_shili'] < 25 && $jiankang[$pianyinGan]['zong_shili'] < 25
                    && (in_array($yunGanShishen, ['七杀', '伤官', '偏印', '劫财'], true)
                        || in_array($yunBenqiShishen, ['七杀', '伤官', '偏印', '劫财'], true))
                    && ($this->isXiongshenJi(1, '七杀', $dayun)
                        || $this->isXiongshenJi(1, '伤官', $dayun)
                        || $this->isXiongshenJi(1, '偏印', $dayun)
                        || $this->isXiongshenJi(1, '劫财', $dayun))
                    && !(
                        (in_array($yunGanShishen, ['正印', '偏印'], true)
                            || in_array($yunBenqiShishen, ['正印', '偏印'], true))
                        && ($this->horoscopeInstance->is_gong($dayun[1], $dizhi[2])
                            || $this->horoscopeInstance->is_liuhe($dayun[1], $dizhi[2])
                            || $this->horoscopeInstance->is_anhe($dayun[1], $dizhi[2])))
                    && !$this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '正官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                )
                {
                    $texts[] = '0403';
                    $qiuxueNum++;
                }
            }
        }

        /**
         * 贵人
         * 高朋满座 0501
         *  情况一：大运亲和不高于3，大运干支本气有比劫，比劫为用神
         *  情况二：大运亲和不高于3，大运干支本气有正官，不见吉受克组合，大运地支或本命地支有贵人
         */
        $guirenNum = 0;
        if ($guirenNum === 0)
        {
            if ($qinheLevel >= 1 && $qinheLevel <= 3 && (
                    (($yongshen[$dayun[0]] > 0 && ($yunGanShishen === '比肩' || $yunGanShishen === '劫财'))
                        || ($yongshen[$dayun[1]] > 0 && ($yunBenqiShishen === '比肩' || $yunBenqiShishen === '劫财')))
                    || (
                        ($yunGanShishen === '正官' || $yunBenqiShishen === '正官')
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                        && ($this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[0])
                            || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[1])
                            || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[2])
                            || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[3])
                            || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dayun[1]))
                    )
                )
            )
            {
                $texts[] = '0501';
                $guirenNum++;
            }
        }
        /**
         * 人助天助 0502
         *  情况一：大运干支本气有比劫，比劫为用神
         *  情况二：大运干支本气有正官或原局正官透干，不见吉受克组合，大运地支或本命地支有贵人
         *  情况三：日干为乙木，运干为甲木
         */
        if ($guirenNum === 0)
        {
            if ((($yongshen[$dayun[0]] > 0 && ($yunGanShishen === '比肩' || $yunGanShishen === '劫财'))
                    || ($yongshen[$dayun[1]] > 0 && ($yunBenqiShishen === '比肩' || $yunBenqiShishen === '劫财')))
                || (
                    ($yunGanShishen === '正官' || $yunBenqiShishen === '正官' || in_array($this->shishens[$tiangan[2]], $tiangan, true))
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && ($this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[0])
                        || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[1])
                        || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[2])
                        || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[3])
                        || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dayun[1]))
                )
                || ($tiangan[2] === '乙' && $dayun[0] === '甲')
            )
            {
                $texts[] = '0502';
                $guirenNum++;
            }
        }
        /**
         * 利官近贵 0503
         *  本命或大运有贵人，大运干或支本气为正官，且运干支之一与日干支之一相合，大运有用神，无吉受克组合
         */
        if ($guirenNum === 0)
        {
            if (($this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[0])
                    || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[1])
                    || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[2])
                    || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dizhi[3])
                    || $this->horoscopeInstance->is_tianyiguiren($tiangan[2], $dayun[1]))
                && ($yunGanShishen === '正官' || $yunBenqiShishen === '正官')
                && ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0)
                && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '正官', 'xing2' => '伤官', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '同性根', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '禄', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && ($this->horoscopeInstance->is_wuhe($dayun[0], $tiangan[2])
                    || $this->horoscopeInstance->is_liuhe($dayun[1], $dizhi[2])
                    || $this->horoscopeInstance->is_anhe($dayun[1], $dizhi[2]))
            )
            {
                $texts[] = '0503';
                $guirenNum++;
            }
        }

        /**
         * 父母
         */
        if ($topic['index'] >= 1 && $topic['index'] <= 5)
        {
            $fumuNum = 0;
            /**
             * 微恙无忧 0602
             *  运中父母有负面值，且财印之一有受克组合但财印健康均不低于0.5
             */
            if ($fumuNum === 0)
            {
                if (($zhuti['fuqin']['gong_fumian'] > 0 || $zhuti['fuqin']['xing_fumian'] > 0 || $zhuti['muqin']['gong_fumian'] > 0 || $zhuti['muqin']['xing_fumian'] > 0)
                    && (
                        ($jiankang[$zhengcaiGan]['jiankang'] >= 0.5
                            && $jiankang[$piancaiGan]['jiankang'] >= 0.5
                            && $jiankang[$zhengyinGan]['jiankang'] >= 0.5
                            && $jiankang[$pianyinGan]['jiankang'] >= 0.5)
                        && $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $texts[] = '0602';
                    $fumuNum++;
                }
            }
            /**
             * 亲孝天年 0603
             *  运中父母有负面值，且财印之一有受克组合且健康低于0.5
             */
            if ($fumuNum === 0)
            {

                if (($zhuti['fuqin']['gong_fumian'] > 0 || $zhuti['muqin']['gong_fumian'] > 0 || $zhuti['fuqin']['xing_fumian'] > 0 || $zhuti['muqin']['xing_fumian'] > 0)
                    && (
                        ($jiankang[$zhengcaiGan]['jiankang'] < 0.5
                            && $jiankang[$piancaiGan]['jiankang'] < 0.5
                            && $jiankang[$zhengyinGan]['jiankang'] < 0.5
                            && $jiankang[$pianyinGan]['jiankang'] < 0.5)
                        && $this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])))
                {
                    $texts[] = '0602';
                    $fumuNum++;
                }
            }
            /**
             * 长乐永康 0601
             *  本命不缺财星、印星，前面运势无“微恙无忧”或“亲孝天年”，运中父母无负面值，无财星或印星受克组合，运支本气非财星或比劫，运支不与本命年月、财印本气支刑冲穿
             */
            if ($fumuNum === 0)
            {
                if (
                    ($zhuti['fuqin']['gong_fumian'] <= 0 && $zhuti['muqin']['gong_fumian'] <= 0 && $zhuti['fuqin']['xing_fumian'] <= 0 && $zhuti['muqin']['xing_fumian'] <= 0)
                    && (in_array($zhengcaiGan, $tiangan, true)
                        || in_array($piancaiGan, $tiangan, true)
                        || in_array($zhengyinGan, $tiangan, true)
                        || in_array($pianyinGan, $tiangan, true))
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '劫财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '偏财', 'xing2' => '比肩', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !$this->zuhePanding(['type' => 0, 'xing1' => '正印', 'xing2' => '正财', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                    && !in_array($yunBenqiShishen, ['正财', '偏财', '比肩', '劫财'], true)
                    && !$this->horoscopeInstance->is_xing($dayun[1], $dizhi[0])
                    && !$this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[0])
                    && !$this->horoscopeInstance->is_liuhai($dayun[1], $dizhi[0])
                    && !$this->horoscopeInstance->is_xing($dayun[1], $dizhi[1])
                    && !$this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[1])
                    && !$this->horoscopeInstance->is_liuhai($dayun[1], $dizhi[1])
                    && (!$this->horoscopeInstance->is_xing($dayun[1], $dizhi[2])
                        || !in_array($shishen[$tiangan[2]][$canggan[$dizhi[2]][0]], ['正财', '偏财', '正印', '偏印'], true))
                    && (!$this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[2])
                        || !in_array($shishen[$tiangan[2]][$canggan[$dizhi[2]][0]], ['正财', '偏财', '正印', '偏印'], true))
                    && (!$this->horoscopeInstance->is_liuhai($dayun[1], $dizhi[2])
                        || !in_array($shishen[$tiangan[2]][$canggan[$dizhi[2]][0]], ['正财', '偏财', '正印', '偏印'], true))
                    && (!$this->horoscopeInstance->is_xing($dayun[1], $dizhi[3])
                        || !in_array($shishen[$tiangan[2]][$canggan[$dizhi[3]][0]], ['正财', '偏财', '正印', '偏印'], true))
                    && (!$this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[3])
                        || !in_array($shishen[$tiangan[2]][$canggan[$dizhi[3]][0]], ['正财', '偏财', '正印', '偏印'], true))
                    && (!$this->horoscopeInstance->is_liuhai($dayun[1], $dizhi[3])
                        || !in_array($shishen[$tiangan[2]][$canggan[$dizhi[3]][0]], ['正财', '偏财', '正印', '偏印'], true)))
                {
                    $texts[] = '0601';
                    $fumuNum++;
                }
            }
        }

        /**
         * 健康
         * 心安身健 0701
         *  本命日干旺或以上，运中无印食日干受克的组合，日干的同性根气也不受刑冲穿，正印食神本气也无刑冲穿，日支不受刑冲穿，大运干支本气要么是用神要么是吉神（非杀伤枭劫）
         *  日干旺=日干的气力值
         *  运中无印食日干受克的组合 无：财印、食枭、日杀组合
         */
        $kangNum = 0;
        if ($kangNum === 0)
        {
            if ($power[$tiangan[2]]['level'] >= 3
                && !$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0
                    || (!in_array($yunGanShishen, ['七杀', '伤官', '偏印', '劫财'], true)
                        && !in_array($yunBenqiShishen, ['七杀', '伤官', '偏印', '劫财'], true)))
            )
            {
                $x7_1_1 = true;
                foreach ($dizhi as $k1 => $v1)
                {
                    $isJianchaXCC = false;
                    foreach ($canggan[$v1] as $k2 => $v2)
                    {
                        if ($v2 === $bijianGan || $k2 === 2 || $v2 === $zhengyinGan || $v2 === $shishenGan)
                        {
                            $isJianchaXCC = true;
                            break;
                        }
                    }
                    if ($isJianchaXCC
                        && ($this->horoscopeInstance->is_xing($v1, $dayun[1])
                            || $this->horoscopeInstance->is_liuchong($v1, $dayun[1])
                            || $this->horoscopeInstance->is_liuhai($v1, $dayun[1])))
                    {
                        $x7_1_1 = false;
                        break;
                    }
                }
                if ($x7_1_1)
                {
                    $texts[] = '0701';
                    $kangNum++;
                }
            }
        }
        /**
         * 康乐无忧 0702
         *  运中无印食日干受克的组合，日干的同性根气也不受刑冲穿，正印食神本气也无刑冲穿，日支本气、大运干支本气、年月时干之一为食神且相邻干支无枭
         */
        if ($kangNum === 0)
        {
            if (!$this->zuhePanding(['type' => 0, 'xing1' => '正财', 'xing2' => '正印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun])
                && !$this->zuhePanding(['type' => 0, 'xing1' => '七杀', 'xing2' => '日干', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
            {
                $x7_2_1 = true;
                $x7_2_2 = false;
                foreach ($dizhi as $k1 => $v1)
                {
                    $isJianchaXCC = false;
                    foreach ($canggan[$v1] as $k2 => $v2)
                    {
                        if ($v2 === $bijianGan || $v2 === $zhengyinGan || $v2 === $shishenGan)
                        {
                            $isJianchaXCC = true;
                        }
                    }
                    if ($isJianchaXCC
                        && ($this->horoscopeInstance->is_xing($v1, $dayun[1])
                            || $this->horoscopeInstance->is_liuchong($v1, $dayun[1])
                            || $this->horoscopeInstance->is_liuhai($v1, $dayun[1])))
                    {
                        $x7_2_1 = false;
                        break;
                    }
                }
                if (($shishen[$canggan[$dizhi[2]][0]][$tiangan[2]] === '食神'
                        && $shishen[$canggan[$dizhi[1]][0]][$tiangan[2]] !== '偏印'
                        && $shishen[$canggan[$dizhi[3]][0]][$tiangan[2]] !== '偏印'
                        && $shishen[$tiangan[1]][$tiangan[2]] !== '偏印'
                        && $shishen[$tiangan[3]][$tiangan[2]] !== '偏印')
                    || ($yunGanShishen === '食神' || $yunBenqiShishen === '食神')
                    || ($shishen[$tiangan[0]][$tiangan[2]] === '食神'
                        && $shishen[$tiangan[1]][$tiangan[2]] === '偏印'
                        && $shishen[$canggan[$dizhi[1]][0]][$tiangan[2]] !== '偏印')
                    || ($shishen[$tiangan[1]][$tiangan[2]] === '食神'
                        && $shishen[$tiangan[0]][$tiangan[2]] === '偏印'
                        && $shishen[$canggan[$dizhi[0]][0]][$tiangan[2]] !== '偏印'
                        && $shishen[$canggan[$dizhi[2]][0]][$tiangan[2]] !== '偏印')
                    || ($shishen[$tiangan[3]][$tiangan[2]] === '食神'
                        && $shishen[$canggan[$dizhi[2]][0]][$tiangan[2]] !== '偏印')
                )
                {
                    $x7_2_2 = true;
                }
                if ($x7_2_1 && $x7_2_2)
                {
                    $texts[] = '0702';
                    $kangNum++;
                }
            }
        }
        /**
         * 小病微伤 0703
         *  运中  出现禄印食本气支被刑冲穿或日干的根气被刑冲穿
         */
        if ($kangNum === 0)
        {
            $x7_3_1 = false;
            foreach ($dizhi as $k1 => $v1)
            {
                $isLuYinShiBenqi = false;
                foreach ($canggan[$v1] as $k2 => $v2)
                {
                    if (!$x7_3_1 && !$isLuYinShiBenqi && $k2 === 0 && in_array($shishen[$v2][$tiangan[2]], ['偏印', '食神'], true))
                    {
                        $isLuYinShiBenqi = true;
                    }
                    if (!$x7_3_1 && ($v2 === $tiangan[2]
                            && ($this->horoscopeInstance->is_xing($v1, $dayun[1])
                                || $this->horoscopeInstance->is_liuchong($v1, $dayun[1])
                                || $this->horoscopeInstance->is_liuhai($v1, $dayun[1])))
                    )
                    {
                        $x7_3_1 = true;
                        break;
                    }
                }
                if (!$x7_3_1 && ($this->horoscopeInstance->is_xing($v1, $dayun[1])
                        || $this->horoscopeInstance->is_liuchong($v1, $dayun[1])
                        || $this->horoscopeInstance->is_liuhai($v1, $dayun[1]))
                    && ($isLuYinShiBenqi || ($dayun[1] === $rilu || in_array($yunBenqiShishen, ['偏印', '食神'], true))))
                {
                    $x7_3_1 = true;
                    break;
                }
            }
            if ($x7_3_1)
            {
                $texts[] = '0703';
                $kangNum++;
            }
        }
        /**
         * 打熬筋骨 0704
         *  日支非食神正印本气或墓库，本命有卯酉冲或申寅冲或同时透庚甲，大运干支本气出现金或木或刑冲日支、日干同性根
         *  日支非食神正印本气或墓库，大运出现卯酉、申寅、庚甲组合，大运干支有劫财或七杀
         */
        if ($kangNum === 0)
        {
            if ($this->muKu[$shishenGan] !== $dizhi[2]
                && $this->muKu[$zhengyinGan] !== $dizhi[2]
                && !in_array($canggan[$dizhi[2]][0], ['食神', '正印'], true))
            {
                $x7_4_1 = false;
                if ((in_array('卯', $dizhi, true) && in_array('酉', $dizhi, true))
                    || (in_array('申', $dizhi, true) && in_array('寅', $dizhi, true))
                    || (in_array('庚', $tiangan, true) && in_array('甲', $tiangan, true)))
                {
                    if (in_array($this->wx[$dayun[0]], ['金', '木'], true)
                        || in_array($this->wx[$canggan[$dayun[1]][0]], ['金', '木'], true)
                        || $this->horoscopeInstance->is_xing($dayun[1], $dizhi[2])
                        || $this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[2])
                    )
                    {
                        $x7_4_1 = true;
                    }
                    if (!$x7_4_1)
                    {
                        foreach ($dizhi as $k1 => $v1)
                        {
                            $isRiganTongxing = false;
                            foreach ($canggan[$v1] as $k2 => $v2)
                            {
                                if ($v2 === $tiangan[2])
                                {
                                    $isRiganTongxing = true;
                                    break;
                                }
                            }
                            if ($isRiganTongxing && ($this->horoscopeInstance->is_xing($dayun[1], $v1)
                                    || $this->horoscopeInstance->is_liuchong($dayun[1], $v1)))
                            {
                                $x7_4_1 = true;
                                break;
                            }
                        }
                    }
                }
                if (!$x7_4_1)
                {
                    // 大运出现卯酉、申寅、庚甲组合，大运干支有劫财或七杀
                    if (($dayun[1] === '卯' && in_array('酉', $dizhi, true))
                        || ($dayun[1] === '酉' && in_array('卯', $dizhi, true))
                        || ($dayun[1] === '申' && in_array('寅', $dizhi, true))
                        || ($dayun[1] === '寅' && in_array('申', $dizhi, true))
                        || ($dayun[0] === '庚' && in_array('甲', $tiangan, true))
                        || ($dayun[0] === '甲' && in_array('庚', $tiangan, true))
                    )
                    {
                        if (in_array($yunGanShishen, ['劫财', '七杀'], true))
                        {
                            $x7_4_1 = true;
                        }
                        if (!$x7_4_1)
                        {
                            foreach ($canggan[$dayun[1]] as $k1 => $v1)
                            {
                                if (in_array($shishen[$v1][$tiangan[2]], ['劫财', '七杀'], true))
                                {
                                    $x7_4_1 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if ($x7_4_1)
                {
                    $texts[] = '0704';
                    $kangNum++;
                }

            }
        }
        /**
         * 磨炼精神 0705
         *  大运出现枭食组合
         *  本命有枭食组合或日支本气为枭或食 此时 大运干支本气见枭或杀
         *      本命有枭食组合：天干与天干，地支与地支，同柱干支
         */
        if ($kangNum === 0)
        {
            $x7_5_1 = false;
            if ($this->zuhePanding(['type' => 0, 'xing1' => '食神', 'xing2' => '偏印', 'tiangan' => $tiangan, 'dizhi' => $dizhi, 'yun' => $dayun]))
            {
                $x7_5_1 = true;
            } elseif (in_array('枭', $this->bazi['shishen1'], true) && in_array('食', $this->bazi['shishen1'], true))
            {
                $x7_5_1 = true;
            } elseif (in_array($shishen[$canggan[$dizhi[2]][0]][$tiangan[2]], ['偏印', '食神'], true)
                && (in_array($yunGanShishen, ['偏印', '七杀'], true)
                    || in_array($yunBenqiShishen, ['偏印', '七杀'], true)))
            {
                $x7_5_1 = true;
            } else
            {
                foreach ($dizhi as $k1 => $v1)
                {
                    if ($k1 === 2) continue;
                    foreach ($canggan[$v1] as $k2 => $v2)
                    {
                        if (($pianyinGan === $tiangan[$k1] && $v2 === $shishenGan)
                            || ($shishenGan === $tiangan[$k1] && $v2 === $pianyinGan))
                        {
                            $x7_5_1 = true;
                            break;
                        }
                    }
                }
                if (!$x7_5_1)
                {
                    // 地支与地支
                    foreach ($dizhi as $k1 => $v1)
                    {
                        foreach ($dizhi as $k2 => $v2)
                        {
                            if (!$x7_5_1 && $k1 !== $k2)
                            {
                                foreach ($canggan[$v1] as $k3 => $v3)
                                {
                                    foreach ($canggan[$v2] as $k4 => $v4)
                                    {
                                        if (!$x7_5_1 && (($pianyinGan === $v3 && $v4 === $shishenGan)
                                                || ($shishenGan === $v3 && $v4 === $pianyinGan)))
                                        {
                                            $x7_5_1 = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if ($x7_5_1)
            {
                $texts[] = '0705';
                $kangNum++;
            }
        }

        /**
         * 出行
         */
        $xingNum = 0;
        /**
         * 远走他乡 0801
         *  本命年月或大运干支或本命日支有伤官，大运与年月刑冲，本命或大运有禄印本气与年月支刑冲
         *  本命年月或大运干支或本命日支有伤官，大运与年月刑冲，日支或时支与年支冲
         * 逻辑修改为：
         *  本命年月或大运干支或本命日支有伤官，大运与年月刑冲
         */
        if ($xingNum === 0)
        {
            if (($this->horoscopeInstance->is_xing($dayun[1], $dizhi[0])
                || $this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[0])
                || $this->horoscopeInstance->is_xing($dayun[1], $dizhi[1])
                || $this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[1])))
            {
                $x8_1_1 = false;
                $isYouShangguan = false;
                for ($i = 0; $i < 3; $i++)
                {
                    if ($i !== 2 && $tiangan[$i] === $shangguanGan)
                    {
                        $isYouShangguan = true;
                        break;
                    }
                    foreach ($canggan[$dizhi[$i]] as $k1 => $v1)
                    {
                        if ($v1 === $shangguanGan)
                        {
                            $isYouShangguan = true;
                            break;
                        }
                    }
                }
                if ($isYouShangguan)
                {
                    $x8_1_1 = true;
//                    // 本命或大运有禄印本气与年月支刑冲
//                    // 日支或时支与年支冲
//                    if ($this->horoscopeInstance->is_liuchong($dizhi[2], $dizhi[0])
//                        || $this->horoscopeInstance->is_liuchong($dizhi[3], $dizhi[0]))
//                    {
//                        $x8_1_1 = true;
//                    }
//                    if (!$x8_1_1)
//                    {
//                        $dizhiTmp = $dizhi;
//                        $dizhiTmp[] = $dayun[1];
//                        foreach ($dizhiTmp as $k1 => $v1)
//                        {
//                            if (($v1 === $rilu || $canggan[$v1][0] === $zhengyinGan)
//                                && ($this->horoscopeInstance->is_xing($dizhi[0], $v1)
//                                    || $this->horoscopeInstance->is_liuchong($dizhi[0], $v1)
//                                    || $this->horoscopeInstance->is_liuchong($dizhi[1], $v1)
//                                    || $this->horoscopeInstance->is_liuchong($dizhi[1], $v1)))
//                            {
//                                $x8_1_1 = true;
//                                break;
//                            }
//                        }
//                    }
                }
                if ($x8_1_1)
                {
                    $texts[] = '0801';
                    $xingNum++;
                }
            }
        }
        /**
         * 奔波往返 0802
         *  运支冲本命禄或印本气支
         *  运支为驿马且受刑冲
         *  运干支与日干支相同
         *  运支冲日支
         *  运干为比肩，运支为寅申巳亥且受刑冲
         */
        $isYiMa = false;
        if ($shensha['驿马'][$dizhi[1]] === $dayun[1] || $shensha['驿马'][$dizhi[2]] === $dayun[1])
        {
            $isYiMa = true;
        }
        $isYunzhiXC = false;
        foreach ($dizhi as $k1 => $v1)
        {
            if ($this->horoscopeInstance->is_xing($dayun[1], $v1)
                || $this->horoscopeInstance->is_liuchong($dayun[1], $v1))
            {
                $isYunzhiXC = true;
            }
        }
        if ($xingNum === 0)
        {
            $x8_2_1 = $x8_2_2 = $x8_2_3 = false;
            foreach ($dizhi as $k1 => $v1)
            {
                if ($x8_2_1 === false && $canggan[$v1][0] === $zhengyinGan && $this->horoscopeInstance->is_liuchong($dayun[1], $v1))
                {
                    $x8_2_1 = true;
                }
                if ($x8_2_2 === false && $isYiMa && $isYunzhiXC)
                {
                    $x8_2_2 = true;
                }
                if ($x8_2_3 === false && $dayun[0] === $tiangan[0] && in_array($dayun[1], ['寅', '申', '巳', '亥'], true)
                    && ($this->horoscopeInstance->is_xing($dayun[1], $v1)
                        || $this->horoscopeInstance->is_liuchong($dayun[1], $v1)))
                {
                    $x8_2_3 = true;
                }
            }

            if ($this->horoscopeInstance->is_liuchong($rilu, $dayun[1] || $x8_2_1)
                || $x8_2_2
                || ($dayun[0] === $tiangan[2] && $dayun[1] === $dizhi[2])
                || $this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[2])
                || $x8_2_3)
            {
                $texts[] = '0802';
                $xingNum++;
            }
        }
        /**
         * 出门见喜 0803
         *  运干支合本命印星干支本气，运有用神
         *  运支为驿马，且运干为财官印食，运支不受刑冲
         */
        if ($xingNum === 0)
        {
            $x8_3_1 = false;
            foreach ($tiangan as $k1 => $v1)
            {
                if (in_array($v1, [$zhengyinGan, $pianyinGan], true)
                    && $this->horoscopeInstance->is_wuhe($v1, $dayun[0]))
                {
                    $x8_3_1 = true;
                    break;
                }
            }
            if (!$x8_3_1)
            {
                foreach ($dizhiBenqiList as $k1 => $v1)
                {
                    if (in_array($v1, [$zhengyinGan, $pianyinGan], true)
                        && ($this->horoscopeInstance->is_liuhe($dayun[1], $v1)
                            || $this->horoscopeInstance->is_anhe($dayun[1], $v1)))
                    {
                        $x8_3_1 = true;
                        break;
                    }
                }
            }
            if (($x8_3_1 && ($yongshen[$dayun[0]] > 0 || $yongshen[$dayun[1]] > 0))
                || ($isYiMa && !$isYunzhiXC && in_array($yunGanShishen, ['正财', '正官', '正印', '食神'], true)))
            {
                $texts[] = '0803';
                $xingNum++;
            }
        }
        /**
         * 磕磕碰碰 0804
         *  大运出现丑未、辰戌、寅申、卯酉冲
         *  运干支本气有劫，运支与日时支或禄刑冲穿
         *  运干支本气有杀，运支与日时支或禄刑冲穿
         *  运干为庚，运支与日时支或禄刑冲穿
         */
        if ($xingNum === 0)
        {
            $x8_4_1 = false;
            if ((($dayun[1] === '丑' && in_array('未', $dizhi, true))
                    || ($dayun[1] === '未' && in_array('丑', $dizhi, true))
                    || ($dayun[1] === '辰' && in_array('戌', $dizhi, true))
                    || ($dayun[1] === '戌' && in_array('辰', $dizhi, true))
                    || ($dayun[1] === '寅' && in_array('申', $dizhi, true))
                    || ($dayun[1] === '申' && in_array('寅', $dizhi, true))
                    || ($dayun[1] === '卯' && in_array('酉', $dizhi, true))
                    || ($dayun[1] === '酉' && in_array('卯', $dizhi, true)))
                || ((($yunGanShishen === '劫财' || $yunBenqiShishen === '劫财')
                        || ($yunGanShishen === '七杀' || $yunBenqiShishen === '七杀')
                        || $dayun[0] === '庚')
                    && ($this->horoscopeInstance->is_xing($dayun[1], $dizhi[2])
                        || $this->horoscopeInstance->is_xing($dayun[1], $dizhi[3])
                        || $this->horoscopeInstance->is_xing($dayun[1], $rilu)
                        || $this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[2])
                        || $this->horoscopeInstance->is_liuchong($dayun[1], $dizhi[3])
                        || $this->horoscopeInstance->is_liuchong($dayun[1], $rilu)
                        || $this->horoscopeInstance->is_liuhai($dayun[1], $dizhi[2])
                        || $this->horoscopeInstance->is_liuhai($dayun[1], $dizhi[3])
                        || $this->horoscopeInstance->is_liuhai($dayun[1], $rilu))))
            {
                $x8_4_1 = true;
            }
            if ($x8_4_1)
            {
                $texts[] = '0804';
                $xingNum++;
            }
        }


        $years = [
            '01' => [],// 婚恋
            '02' => [],// 财富
            '03' => [],// 事业
            '04' => [],// 学业
            '05' => [],// 贵人
            '06' => [],// 父母
            '07' => [],// 健康
            '08' => [],// 出行
            '09' => [],// 子女
            '10' => [],// 技艺
        ];
        $liunianshaixuan = $this->liunianShaixuan(false, true);
        $liunianfenleiliebiao = [];
        foreach ($liunianshaixuan as $k1 => $v1)
        {
            $liunianfenleiliebiao[$v1['type']][] = $v1;
        }
        foreach ($liunianfenleiliebiao as $k1 => $v1)
        {
            // 按等级倒序
            $liunianfenleiliebiao[$k1] = resort($v1, 'level', 'DESC');
        }
        //  1=>桃花、2=>婚姻、3=>财富、4=>事业、5=>灾病
        $issetShiye = false;
        if (isset($liunianfenleiliebiao[1]))
        {
            $years['01'][] = $liunianfenleiliebiao[1][0]['year'];
            if (isset($liunianfenleiliebiao[2]))
            {
                $years['01'][] = $liunianfenleiliebiao[2][0]['year'];
            } elseif (isset($liunianfenleiliebiao[1][1]))
            {
                $years['01'][] = $liunianfenleiliebiao[1][1]['year'];
            }
        } elseif (isset($liunianfenleiliebiao[2]))
        {
            $years['01'][] = $liunianfenleiliebiao[2][0]['year'];
            if (isset($liunianfenleiliebiao[2][1]))
            {
                $years['01'][] = $liunianfenleiliebiao[2][1]['year'];
            }
        }
        if (isset($liunianfenleiliebiao[3]))
        {
            $years['02'][] = $liunianfenleiliebiao[3][0]['year'];
            if (isset($liunianfenleiliebiao[3][1]))
            {
                $years['02'][] = $liunianfenleiliebiao[3][1]['year'];
            }
        }
        if (isset($liunianfenleiliebiao[4]))
        {
            $years['03'][] = $liunianfenleiliebiao[4][0]['year'];
            if (isset($liunianfenleiliebiao[4][1]))
            {
                $years['03'][] = $liunianfenleiliebiao[4][1]['year'];
            }
        }
        if (isset($liunianfenleiliebiao[5]))
        {
            $years['07'][] = $liunianfenleiliebiao[5][0]['year'];
            if (isset($liunianfenleiliebiao[5][1]))
            {
                $years['07'][] = $liunianfenleiliebiao[5][1]['year'];
            }
        }
        /**
         * 大运重点流年
         * 1、大运干或支在流年再次出现；
         * 2、大运干的禄在流年出现
         * 3、流年干的禄是大运支
         * 4、流年与大运天干相克，地支相冲
         * 5、流年与本命日柱天干相克，地支相冲
         * 6、流年与大运天干五合，地支六合或暗合
         * 7、流年与本命日柱天干五合，地支六合或暗合
         * 8、流年干支与日柱干支相同
         * 9、流年干与日干同，流年支与日支冲
         * 补充逻辑：如以上结果不多于1，取年干为七杀的流年、年干与大运干相合的流年
         */
        foreach ($this->bazi['dayun'] as $k1 => $v1)
        {
            // 进行中的大运 [-1已过去｜0进行中｜1未开始]
            if ($this->advance['year'] >= $v1['start_year'] && $this->advance['year'] <= $v1['end_year'])
            {
                $topic['index'] = $k1 + 1;
                $topic['start'] = $v1['start_year'];
                $topic['end'] = $v1['end_year'];
                $dy = [mb_substr($v1['name'], 0, 1), mb_substr($v1['name'], 1, 1)];
                $zuidaHunlianDongtai = 0;
                $fumuDongtaiMax = 0;
                $fumuFumianMax = 0;
                $fumuDongtaiMaxYear = $v1['start_year'];
                $fumuFumianMaxYear = $v1['start_year'];
                $chuxingDongtaiMax = 0;
                $hunlianYear = $v1['start_year'];
                $caifuYears = [];
                $shiyeYears = [];
                $xueyeYears = [];
                $guirenYears = [];
                $jiankangYears = [];
                $chuxingYears1 = 0;
                $chuxingYears2 = 0;
                $zinvYears = [];
                $jiyiYears = [];
                foreach ($this->bazi['liunian'][$k1] as $k2 => $v2)
                {
                    // 当前大运下的流年
                    $ln = [mb_substr($v2['name'], 0, 1), mb_substr($v2['name'], 1, 1)];
                    // 取婚恋动态最高的流年
                    if (empty($years['01']))
                    {
                        $hunlianLiunianZhuti = $this->zhuti('', $this->bazi['bazi'][6], $fuqiXing, $dy, $ln, 2);
                        $dt = $hunlianLiunianZhuti['gong_dongtai'] + $hunlianLiunianZhuti['xing_dongtai'];
                        if ($dt > $zuidaHunlianDongtai)
                        {
                            $zuidaHunlianDongtai = $dt;
                            $hunlianYear = $v2['year'];
                        }
                    }
                    // 取年干为偏财的流年
                    if (empty($years['02']))
                    {
                        if ($shishen[$ln[0]][$tiangan[2]] === '偏财')
                        {
                            $caifuYears[] = $v2['year'];
                        }
                    }
                    // 运干为杀 取年干为食神的流年
                    // 否则 取年干为正官的流年
                    if (empty($years['03']))
                    {
                        if (($shishen[$dy[0]][$tiangan[2]] === '七杀' && $shishen[$ln[0]][$tiangan[2]] === '食神')
                            || ($shishen[$dy[0]][$tiangan[2]] !== '七杀' && $shishen[$ln[0]][$tiangan[2]] === '正官'))
                        {
                            $shiyeYears[] = $v2['year'];
                        }
                    }
                    // 运干为杀 取流年支本气为杀的流年一，多则取亲和最低的，无则取比肩在天干的流年
                    // 运干为枭 取食神在天干的流年
                    // 其它 取七杀在天干的流年
                    if (empty($years['07']))
                    {
                        if (($shishen[$dy[0]][$tiangan[2]] === '七杀' && $shishen[$canggan[$ln[1]][0]][$tiangan[2]] === '七杀')
                            || ($shishen[$dy[0]][$tiangan[2]] === '偏印' && $shishen[$ln[0]][$tiangan[2]] === '食神')
                            || ($shishen[$dy[0]][$tiangan[2]] !== '七杀'
                                && $shishen[$dy[0]][$tiangan[2]] !== '偏印'
                                && $shishen[$ln[0]][$tiangan[2]] === '七杀'))
                        {
                            $jiankangYears[] = $v2['year'];
                        }
                    }
                    // 学业
                    //	运干为正偏印 取正偏印被合的流年
                    //	其它 取正偏印在天干的流年
                    if (
                        (in_array($shishen[$dy[0]][$tiangan[2]], ['正印', '偏印'], true) && $this->horoscopeInstance->is_wuhe($dy[0], $ln[0]))
                        || (!in_array($shishen[$dy[0]][$tiangan[2]], ['正印', '偏印'], true) && in_array($shishen[$ln[0]][$tiangan[2]], ['正印', '偏印'], true))
                    )
                    {
                        $xueyeYears[] = $v2['year'];
                    }
                    // 贵人
                    //	取大运与流年有杀组合的流年，如无，取正官在干支本气不受克的流年
                    if ($this->zuhePanding(['type' => 1, 'xing1' => '正印', 'xing2' => '七杀', 'tiangan' => [$dy[0]], 'dizhi' => [$dy[1]], 'yun' => $ln])
                        || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '食神', 'tiangan' => [$dy[0]], 'dizhi' => [$dy[1]], 'yun' => $ln])
                        || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '合干', 'tiangan' => [$dy[0]], 'dizhi' => [$dy[1]], 'yun' => $ln])
                        || $this->zuhePanding(['type' => 2, 'xing1' => '七杀', 'xing2' => '正印', 'tiangan' => [$dy[0]], 'dizhi' => [$dy[1]], 'yun' => $ln])
                    )
                    {
                        $guirenYears[] = $v2['year'];
                    } else
                    {
                        if ($shishen[$ln[0]][$tiangan[2]] === '正官' || $shishen[$canggan[$ln[1]][0]][$tiangan[2]] === '正官')
                        {
                            $guirenYears[] = $v2['year'];
                        }
                    }
                    // 父母
                    //	取年宫动态最高的流年一，年宫负面值最高的流年一
                    $fuqin = $this->zhuti($bazi[1], $bazi[2], ['正财', '偏财'], $dy, $ln, 2);
                    $muqin = $this->zhuti($bazi[1], $bazi[2], ['正印', '偏印'], $dy, $ln, 2);
                    $fmdongtai = $fuqin['gong_dongtai'] + $fuqin['xing_dongtai'] + $muqin['gong_dongtai'] + $muqin['xing_dongtai'];
                    $fmfumian = $fuqin['gong_fumian'] + $fuqin['xing_fumian'] + $muqin['gong_fumian'] + $muqin['xing_fumian'];
                    if ($fmdongtai > $fumuDongtaiMax)
                    {
                        $fumuDongtaiMaxYear = $v2['year'];
                    }
                    if ($fmfumian > $fumuFumianMax)
                    {
                        $fumuFumianMaxYear = $v2['year'];
                    }
                    // 出行
                    //	取日支逢冲的流年与印星动态最高的流年
                    if ($chuxingYears1 === 0 && $this->horoscopeInstance->is_liuchong($dizhi[2], $ln[1]))
                    {
                        $chuxingYears1 = $v2['year'];
                    }
                    $yinXingChuxing = $this->zhuti($bazi[1], $bazi[2], ['正印', '偏印'], $dy, $ln, 2);
                    if ($yinXingChuxing['xing_dongtai'] > $chuxingDongtaiMax)
                    {
                        $chuxingYears2 = $v2['year'];
                    }
                    // 子女
                    //	仅女命取。取食神在年干或年支本气的流年前二
//                    if ($sex === 2 && ($shishen[$ln[0]][$tiangan[2]] === '食神' || $shishen[$canggan[$ln[1]][0]][$tiangan[2]] === '食神'))
//                    {
//                        $zinvYears[] = $v2['year'];
//                    }
                    // 技艺
                    //	取有偏印合伤官组合的流年，伤官正印组合的流年，如无，取食神出干的流年
//                    $jiyiYears[] = $v2['year'];
                }
                if (empty($years['01']))
                {
                    $years['01'][] = $hunlianYear;
                }
                if (empty($years['02']) && !empty($caifuYears))
                {
                    $years['02'] = array_slice($caifuYears, 0, 2);
                }
                if (empty($years['03']) && !empty($shiyeYears))
                {
                    $years['03'] = array_slice($shiyeYears, 0, 2);
                }
                if (empty($years['07']) && !empty($jiankangYears))
                {
                    $years['07'] = array_slice($jiankangYears, 0, 2);
                }
                if (!empty($xueyeYears))
                {
                    $years['04'] = array_slice($xueyeYears, 0, 2);
                }
                if (!empty($guirenYears))
                {
                    $years['05'] = array_slice($guirenYears, 0, 2);
                }
                if ($fumuDongtaiMax > 0)
                {
                    $years['06'][] = $fumuDongtaiMaxYear;
                }
                if ($fumuFumianMax > 0)
                {
                    $years['06'][] = $fumuFumianMaxYear;
                }
                if ($chuxingYears1 > 0)
                {
                    $years['08'][] = $chuxingYears1;
                }
                if ($chuxingYears2 > 0)
                {
                    $years['08'][] = $chuxingYears2;
                }
                break;
            }
        }
        $text_list = [];
        foreach ($texts as $k1 => $v1)
        {
            $key = substr($v1, 0, 2);
            $text_list[] = [
                'code' => $v1,
                'years' => $years[$key],
            ];
        }
        // , 'year_list' => $years
        return ['topic' => $topic, 'text_list' => $text_list];
    }

    /**
     * 判断凶神的忌状态
     *    1、流运干出现凶神克吉神组合（枭食、财劫、官伤、杀日干）同时支与原局日时冲穿刑（如无，与日禄、本气正印、正官、食神冲穿刑也算）
     *    2、流运支本气出现凶神克吉神组合（通过刑冲穿），同时天干为杀伤枭劫
     * @param int $type 0=>本命,1=>大运,2=>流年
     * @param string $xing1
     * @param array $dayun
     * @param array $liunian
     * @return bool
     */
    protected function isXiongshenJi($type = 0, $xing1 = '', $dayun = [], $liunian = []): bool
    {
        // 正财 财 我克者，同性为偏财，异性为正财
        // 偏财 才
        // 正印 印 生我者，同性为偏印，异性为正印
        // 偏印 枭
        // 食神 食 我生者，同性为食神，异性为伤官
        // 伤官 伤
        // 比肩 比 同我者，同性为比肩，异性为劫财
        // 劫财 劫
        // 七杀 杀 克我者，同性为七杀，异性为正官
        // 正官 官
        $res = false;
        if ($type === 0) return $res;
        // 天干
        $tiangan = [$this->bazi['bazi'][1], $this->bazi['bazi'][3], $this->bazi['bazi'][5], $this->bazi['bazi'][7]];
        // 地支
        $dizhi = [$this->bazi['bazi'][2], $this->bazi['bazi'][4], $this->bazi['bazi'][6], $this->bazi['bazi'][8]];
        if ($type === 2)
        {
            $tiangan[] = $dayun[0];
            $dizhi[] = $dayun[1];
            $yun = $liunian;
        } else
        {
            $yun = $dayun;
        }
        $ok = [['偏印', '食神'], ['正财', '劫财'], ['正官', '伤官'], ['七杀', '日干']];
        // 支与原局日时冲穿刑（如无，与日禄、本气正印、正官、食神冲穿刑也算）
        $yunGanShishen = $this->horoscopeInstance->param['shishen'][$yun[0]][$tiangan[2]];
        $isYunZhi = false;
        if ($this->horoscopeInstance->is_liuchong($yun[1], $dizhi[2])
            || $this->horoscopeInstance->is_liuhai($yun[1], $dizhi[2])
            || $this->horoscopeInstance->is_xing($yun[1], $dizhi[2]))
        {
            $isYunZhi = true;
        } else
        {
            $rilu = $this->horoscopeInstance->param['shensha']['禄神'][$tiangan[2]];
            if ($this->horoscopeInstance->is_liuchong($yun[1], $rilu)
                || $this->horoscopeInstance->is_liuhai($yun[1], $rilu)
                || $this->horoscopeInstance->is_xing($yun[1], $rilu))
            {
                $isYunZhi = true;
            }
            foreach ($this->bazi['shishen2'] as $k1 => $v1)
            {
                $benqiShishen = mb_substr($v1, 0, 1);
                if ($res === false
                    && in_array($benqiShishen, ['印', '官', '食'], true)
                    && ($this->horoscopeInstance->is_liuchong($yun[1], $dizhi[$k1])
                        || $this->horoscopeInstance->is_liuhai($yun[1], $dizhi[$k1])
                        || $this->horoscopeInstance->is_xing($yun[1], $dizhi[$k1])))
                {
                    $isYunZhi = true;
                }
            }
        }
        if ($isYunZhi)
        {
            $isTiangan = false;
            // 流运干出现凶神克吉神组合（枭食、财劫、官伤、杀日干）
            foreach ($ok as $k1 => $v1)
            {
                if (in_array($xing1, $v1, true))
                {
                    $index1 = array_search($yunGanShishen, $v1, true);
                    $index2 = $index1 === 0 ? 1 : 0;
                    if ($v1[$index2] !== '日干')
                    {
                        foreach ($tiangan as $k2 => $v2)
                        {
                            if ($k2 === 2) continue;
                            $tianganShishen = $this->horoscopeInstance->param['shishen'][$v2][$tiangan[2]];
                            if ($v1[$index2] === $tianganShishen)
                            {
                                $isTiangan = true;
                                break;
                            }
                        }
                    } else
                    {
                        $isTiangan = true;
                    }
                }
            }
            if ($isTiangan)
            {
                $res = true;
            }
        }
        // 运干为杀伤枭劫
        if ($res === false)
        {
            // 流运支本气出现凶神克吉神组合（通过刑冲穿），同时运干为杀伤枭劫
            $yunBenqi = $this->horoscopeInstance->param['canggan'][$yun[1]][0];
            $yunBenqiShishen = $this->horoscopeInstance->param['shishen'][$yunBenqi][$tiangan[2]];
            $yunGanZhiShishen = [$yunGanShishen, $yunBenqiShishen];
            if (in_array('七杀', $yunGanZhiShishen, true)
                || (in_array('伤官', $yunGanZhiShishen, true) && in_array('正官', $yunGanZhiShishen, true))
                || (in_array('偏印', $yunGanZhiShishen, true) && in_array('食神', $yunGanZhiShishen, true))
                || (in_array('正财', $yunGanZhiShishen, true) && in_array('劫财', $yunGanZhiShishen, true)))
            {
                $res = true;
            }
        }
        return $res;
    }

    private function modScore($score = 0, $min = 0, $max = 100)
    {
        if ($score < $min)
        {
            $score = $min;
        } elseif ($score > $max)
        {
            $score = $max;
        }
        return $score;
    }

    /**
     * 吉受克、吉受生、凶受制组合判定
     * @param array $option
     *   type int 0=>吉受克组合,1=>吉受生组合,2=>凶受制组合
     *   xing1 string 十神或其他
     *   xing2 string 十神或其他
     *   tiangan array
     *   dizhi array
     *   yun array 大运或者流年的干支
     *  若传入的yun为大运，则天干里面只有命局天干
     *  若传入的yun为流年，则天干里面有命局天干和大运天干
     *  若传入的yun为空，则仅计算原局
     *      吉受克组合
     *          财+劫，才+比，官+伤，食+枭，印+财，杀+日干，杀+同性根，杀+禄
     *      吉受生组合
     *          财+食，财+伤，才+食，才+伤，官+财，官+才，食+比，食+劫，印+官，印+杀
     *      凶受制组合
     *          1类：伤+印，劫+官，杀+食，枭+才
     *          2类：伤+合干，劫+杀合，杀+合干，枭+合干
     *          3类：伤+财，伤+才，劫+食，杀+印
     * @return bool
     */
    public function zuhePanding($option = []): bool
    {
        $res = false;
        $rigan = $this->bazi['bazi'][5];
        $shishen = $this->horoscopeInstance->param['shishen'];
        $canggan = $this->horoscopeInstance->param['canggan'];
        $shensha = $this->horoscopeInstance->param['shensha'];
        $yunGanShishen = (isset($option['yun'][0]) && $option['yun'][0]) ? $shishen[$option['yun'][0]][$rigan] : '';
        $yunBenqi = (isset($option['yun'][1]) && $option['yun'][1]) ? $canggan[$option['yun'][1]][0] : '';
        $yunBenqiShishen = $yunBenqi ? $shishen[$yunBenqi][$rigan] : '';
        // 地支关系仅计算本气 和 土藏气(辰戌丑未非本气)
        $dizhiCangganList = [];
        $dizhiCangganKVList = [];
        if (!empty($option['dizhi']))
        {
            foreach ($option['dizhi'] as $k1 => $v1)
            {
                foreach ($canggan[$v1] as $k2 => $v2)
                {
                    if ($k2 === 0)
                    {
                        $dizhiCangganList[] = $v2;
                        $dizhiCangganKVList[$k1][] = $v2;
                    }
//                    // 非土藏气仅记录本气
//                    if (!in_array($v1, ['辰', '戌', '丑', '未'], true))
//                    {
//                        if ($k2 === 0)
//                        {
//                            $dizhiCangganList[] = $v2;
//                            $dizhiCangganKVList[$k1][] = $v2;
//                        }
//                    } else
//                    {
////                        // 土藏气仅记录非本气
////                        if ($k2 !== 0)
////                        {
////                            $dizhiCangganList[] = $v2;
////                            $dizhiCangganKVList[$k1][] = $v2;
////                        }
//                        $dizhiCangganList[] = $v2;
//                        $dizhiCangganKVList[$k1][] = $v2;
//                    }
                }
            }
        }
        $yunZhiCangqiList = [];
        if (isset($option['yun'][1]) && $option['yun'][1] !== '')
        {
            foreach ($canggan[$option['yun'][1]] as $k1 => $v1)
            {
                $isBenqi = $k1 === 0;
                // 非土藏气仅记录本气
                if (!in_array($option['yun'][1], ['辰', '戌', '丑', '未'], true))
                {
                    if ($isBenqi)
                    {
                        $yunZhiCangqiList[] = $v1;
                    }
                } else
                {
                    // 土藏气仅记录非本气
                    if (!$isBenqi)
                    {
                        $yunZhiCangqiList[] = $v1;
                    }
                }
            }
        }

        // 吉受克组合
        // 财+劫，才+比，官+伤，食+枭，印+财，杀+日干，杀+同性根，杀+禄
        if ($option['xing1'] === '七杀' && in_array($option['xing2'], ['日干', '同性根', '禄'], true))
        {
            $qishaGan = $this->shishens[$rigan]['七杀'];
            if ($option['xing2'] === '日干')
            {
                // 七杀+日干
                if (isset($option['yun'][0]) && $qishaGan === $option['yun'][0])
                {
                    $res = true;
                }
                return $res;
            }
            $option['xing2'] = '比肩';
//            // 七杀+唯一同性根(日干的比肩)
//            if ($option['xing2'] === '同性根')
//            {
//                $allCangganList = array_merge($dizhiCangganList, $yunZhiCangqiList);
//                $countValues = array_count_values($allCangganList);
//                // 有唯一同性根
//                if (isset($countValues[$rigan]) && $countValues[$rigan] === 1)
//                {
//                    foreach ($dizhiCangganKVList as $k1 => $v1)
//                    {
//                        // 七杀在运支
//                        // 唯一同性根在运支
//                        if ((in_array($rigan, $v1, true) && in_array($qishaGan, $yunZhiCangqiList, true))
//                            || (in_array($qishaGan, $v1, true) && in_array($rigan, $dizhiCangganList, true)))
//                        {
//                            $dizhi1 = $option['yun'][1];
//                            $dizhi2 = $option['dizhi'][$k1];
//                            if ($this->horoscopeInstance->is_xing($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_liuchong($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_liuhai($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_liuhe($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_anhe($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_gong($dizhi1, $dizhi2))
//                            {
//                                $res = true;
//                                break;
//                            }
//                        }
//                    }
//                }
//                return $res;
//            }
//
//            // 七杀+禄
//            if ($option['xing2'] === '禄')
//            {
//                $lu = $shensha['禄神'][$rigan];
//                if (($lu === $option['yun'][1] && in_array($qishaGan, $dizhiCangganList, true))
//                    || (in_array($lu, $option['dizhi'], true)
//                        && in_array($qishaGan, $yunZhiCangqiList, true)))
//                {
//                    foreach ($dizhiCangganKVList as $k1 => $v1)
//                    {
//                        if (($lu === $option['yun'][1] && in_array($qishaGan, $v1, true))
//                            || ($lu === $v1 && in_array($qishaGan, $yunZhiCangqiList, true)))
//                        {
//                            $dizhi1 = $option['yun'][1];
//                            $dizhi2 = $option['dizhi'][$k1];
//                            if ($this->horoscopeInstance->is_xing($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_liuchong($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_liuhai($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_liuhe($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_anhe($dizhi1, $dizhi2)
//                                || $this->horoscopeInstance->is_gong($dizhi1, $dizhi2))
//                            {
//                                $res = true;
//                                break;
//                            }
//                        }
//                    }
//                }
//                return $res;
//            }
        }
        if (strpos($option['xing2'], '合') !== false)
        {
            $gan = array_merge($option['tiangan'], $dizhiCangganList);
            // 有合干/杀合
            foreach ($gan as $k1 => $v1)
            {
                // 合
                if (isset($option['yun'][0])
                    && $this->horoscopeInstance->is_wuhe($v1, $option['yun'][0])
                    && $shishen[$v1][$rigan] === $option['xing1'])
                {
                    if ($option['xing2'] === '合干')
                    {
                        $res = true;
                        break;
                    }

                    if ($option['xing2'] === '杀合' && ($shishen[$v1][$rigan] === '七杀' || $yunGanShishen === '七杀'))
                    {
                        $res = true;
                        break;
                    }
                }
            }
        } else
        {
            $xingGan1 = $this->shishens[$rigan][$option['xing1']];
            $xingGan2 = $this->shishens[$rigan][$option['xing2']];
            // 天干与天干直接作用
            foreach ($option['tiangan'] as $k1 => $v1)
            {
                // 过滤日柱天干
                if ($k1 === 2) continue;
                if (isset($option['yun'][0])
                    && (($xingGan1 === $v1 && $xingGan2 === $option['yun'][0])
                        || ($xingGan1 === $option['yun'][0] && $xingGan2 === $v1)))
                {
                    $res = true;
                }
            }
            // 大运干支相互作用
            if ($res !== true)
            {
                if (($xingGan1 === $option['yun'][0] && in_array($xingGan2, $yunZhiCangqiList, true))
                    || ($xingGan2 === $option['yun'][0] && in_array($xingGan1, $yunZhiCangqiList, true)))
                {
                    $res = true;
                }
            }
            // 地支与地支有关系作用
            if ($res !== true)
            {
                foreach ($dizhiCangganKVList as $k1 => $v1)
                {
                    if ((in_array($xingGan1, $v1, true) && in_array($xingGan2, $yunZhiCangqiList, true))
                        || (in_array($xingGan2, $v1, true) && in_array($xingGan1, $yunZhiCangqiList, true)))
                    {
                        $dizhi1 = $option['yun'][1];
                        $dizhi2 = $option['dizhi'][$k1];
                        if ($option['type'] === 1)
                        {
                            if ($this->horoscopeInstance->is_liuhe($dizhi1, $dizhi2)
                                || $this->horoscopeInstance->is_anhe($dizhi1, $dizhi2)
                                || $this->horoscopeInstance->is_gong($dizhi1, $dizhi2))
                            {
                                $res = true;
                                break;
                            }
                        } else
                        {
                            if ($this->horoscopeInstance->is_xing($dizhi1, $dizhi2)
                                || $this->horoscopeInstance->is_liuchong($dizhi1, $dizhi2)
                                || $this->horoscopeInstance->is_liuhai($dizhi1, $dizhi2)
                                || $this->horoscopeInstance->is_liuhe($dizhi1, $dizhi2)
                                || $this->horoscopeInstance->is_anhe($dizhi1, $dizhi2)
                                || $this->horoscopeInstance->is_gong($dizhi1, $dizhi2))
                            {
                                $res = true;
                                break;
                            }
                        }
                    }
                }
            }
            return $res;
        }
        return $res;
    }

    private function getLevel($score)
    {
        if ($score <= 2)
        {
            $level = 1;
        } elseif ($score <= 3)
        {
            $level = 2;
        } else
        {
            $level = 3;
        }
        return $level;
    }

    /**
     * 获取八字解读信息
     */
    public function bazijiedu(): array
    {
        $wuxingColor = [
            '木' => '#5BBB87',
            '火' => '#EC8337',
            '土' => '#C5C0C0',
            '金' => '#FDC756',
            '水' => '#5F7CEE',
        ];
        $res = [
            'wuxing' => [
                'title' => '五行比例',
                'des' => '专属于你的五行特质',
                'list' => [
                    [
                        'name' => '金',
                        'color' => $wuxingColor['金'],
                        'score' => 1,
                    ],
                    [
                        'name' => '木',
                        'color' => $wuxingColor['木'],
                        'score' => 1,
                    ],
                    [
                        'name' => '水',
                        'color' => $wuxingColor['水'],
                        'score' => 1,
                    ],
                    [
                        'name' => '火',
                        'color' => $wuxingColor['火'],
                        'score' => 1,
                    ],
                    [
                        'name' => '土',
                        'color' => $wuxingColor['土'],
                        'score' => 1,
                    ],
                ],
                'intro' => [
                    'title' => '你的五行特质：',
                    'tag' => '火中金',
                    'content' => '你在烈火中锤炼出的金子，你会经历丰富的人生，同时将收获不错的成绩。',
                ],
            ],
            'shishen' => [
                'title' => '十神强弱',
                'des' => '点击柱状图查看详细解析',
                'list' => [
                    [
                        'name' => '比肩',
                        'color' => '',
                        'score' => 1,
                        'content' => '比肩，本意是指肩并肩，用来形容兄弟、朋友并肩而行，所以在八字中，比肩是兄弟之星，代表自己的兄弟姐妹，朋友同学，各种同辈关系。比肩强势的人，心性刚健、勇敢自立，能积极进取，有担当有能力，但往往比较自我，不太能听信意见。',
                    ],
                    [
                        'name' => '劫财',
                        'color' => '',
                        'score' => 1,
                        'content' => '劫财，本意是“抢劫钱财”，在八字里，劫财是破坏财运的星，花钱随性，但也会让一个人有赌运，有机会通过炒股、彩票等投机方式赚钱。它也代表兄弟姐妹，同辈朋友，能增强你的声势，给你壮胆，所以劫财强旺，会让人勇敢、勇于冒险，甚至鲁莽好斗。',
                    ],
                    [
                        'name' => '食神',
                        'color' => '',
                        'score' => 1,
                        'content' => '食神，本意是“饮食之神”，在八字里是代表吃喝玩乐等各种娱乐享受的星。食神强旺的人有福气，能吃能睡，喜好自由，常常有某些娱乐爱好，也可能有文艺天赋、一技之长，喜欢轻松自自在的生活。食神也有长寿的象征，在女命中代表子女。',
                    ],
                    [
                        'name' => '伤官',
                        'color' => '',
                        'score' => 1,
                        'content' => '伤官，官是“管”的意思，伤官即“伤害管束自己的人”，是颗桀骜不驯、不服管束的星。头脑灵活，不拘一格，善于创新，往往有亮眼的才华。伤官强旺的人比较不安分，工作生活充满变化，适合精通一两门技艺，靠出众的口才、头脑或技术谋生。',
                    ],
                    [
                        'name' => '正财',
                        'color' => '',
                        'score' => 1,
                        'content' => '正财，是正当方式所得的财，一般指工作报酬、交易所得，一分汗水一分收获。八字中除了代表钱，也代表男性的妻子。正财强旺的人务实、踏实，理财能力强，重视和珍惜金钱，较为朴实节俭（有一些是舍不得给别人花，但舍得给自己花）',
                    ],
                    [
                        'name' => '偏财',
                        'color' => '',
                        'score' => 1,
                        'content' => '偏财，是偏门方式所得的财，比如炒股，彩票，遗产，他人赠与等等，来的轻松，去的容易。八字中除了象征钱，也代表父亲、男性的情人等，偏财强旺的人脑筋活，财路广，花销也大，出手阔绰，如果是男性，异性缘非常好，但也较容易花天酒地。',
                    ],
                    [
                        'name' => '正官',
                        'color' => '',
                        'score' => 1,
                        'content' => '正官，就是“正管”的意思，代表自己的顶头上司、管理者、约束自己的长辈，也代表自律、自尊、名誉等等。正官强旺的人自尊心强，要面子，对自己的名誉比较看重，稳重，有正气，遵纪守法，工作努力负责，容易出名、掌权或受人尊重，是地位的象征。',
                    ],
                    [
                        'name' => '七杀',
                        'color' => '',
                        'score' => 1,
                        'content' => '七杀，代表克制、打压甚至伤害自己的人事物，往往带来压力、灾病、意外之类，但也经常带来权利和成功。七杀强旺的人事业心强，但压力大，人生起伏变化较多，女命容易受男性欺负或有较多的烂桃花。所以七杀需适度，不宜太旺。',
                    ],
                    [
                        'name' => '正印',
                        'color' => '',
                        'score' => 1,
                        'content' => '正印，代表无私的帮助和庇护自己的人，如亲生母亲、慈爱的长辈，还代表我们的学业、文凭、房产、工作单位，与我们生活的稳定和安全感息息相关。正印强旺的人会比较懒，会得到很多关爱和照顾，爱学习，爱思考，喜静不喜动，生活平顺很少有辛苦忧虑的事情。',
                    ],
                    [
                        'name' => '偏印',
                        'color' => '',
                        'score' => 1,
                        'content' => '偏印，代表有私心的帮助和庇护自己的人，如继母、亲缘较远的长辈等，还代表偏门、冷门的学问。偏印强旺的人能深入思考，另辟蹊径，有自己的观点和想法，学习容易偏科，有时显得孤僻忧郁，或是有一些怪脾气不好相处，会学一些偏门的学术或爱好，比如命理玄学之类。',
                    ],
                ]
            ],
        ];
        $this->horoscopeInstance = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $this->advance]);
        $this->bazi = $this->horoscopeInstance->getUserData();
        // 五行比例信息
        $wx = $this->bazi['wuxing'];
        foreach ($res['wuxing']['list'] as $k1 => $v1)
        {
            $res['wuxing']['list'][$k1]['score'] = $wx[$v1['name']];
        }
        /**
         * 五行特质信息
         *  找出五行比例最高的、找出日干的五行
         *  对应特质的关键词和词条
         */
        // 五行中比例最高的数值
        $wuxingMax = max($wx);
        // 根据最高数值，找出对应的五行
        $maxWuxing = array_search($wuxingMax, $wx, true);
        // 日干的五行
        $riganWx = $this->horoscopeInstance->param['wuxing'][$this->bazi['bazi'][5]];
        $baziConfig = config('bazi.wuxingtezhi');
        $res['wuxing']['intro']['tag'] = $baziConfig[$this->bazi['bazi'][5]][$maxWuxing]['tag'];
        $res['wuxing']['intro']['content'] = '你的日干是' . $this->bazi['bazi'][5] . $riganWx . '，' . $maxWuxing . '是你最旺的五行。';
        $res['wuxing']['intro']['content'] .= $baziConfig[$this->bazi['bazi'][5]][$maxWuxing]['text'];

        // 十神强弱信息：使用气力值
        $power = $this->tianganPower();
        foreach ($res['shishen']['list'] as $k1 => $v1)
        {
            $tg = $this->shishens[$this->bazi['bazi'][5]][$v1['name']];
            $score = (int)($power[$tg]['score'] * 4);
            if ($score > 99) $score = 99;
            elseif ($score < 1) $score = 1;
            $res['shishen']['list'][$k1]['score'] = $score;
            // 获取当前十神的五行颜色
            $res['shishen']['list'][$k1]['color'] = $wuxingColor[$this->wx[$tg]];
            // 0 => ['name' => '困难', 'color' => '#7775ff',],
            // 1 => ['name' => '警戒', 'color' => '#ffa536',],
            // 2 => ['name' => '平平', 'color' => '#ffed17',],
            // 3 => ['name' => '吉利', 'color' => '#00f4e7',],
            // 4 => ['name' => '大吉', 'color' => '#00e9a0',],
//            if ($power[$tg]['level'] <= 1)
//            {
//                $res['shishen']['list'][$k1]['color'] = '#7775ff';
//            } elseif ($power[$tg]['level'] <= 2)
//            {
//                $res['shishen']['list'][$k1]['color'] = '#ffa536';
//            } elseif ($power[$tg]['level'] <= 3)
//            {
//                $res['shishen']['list'][$k1]['color'] = '#ffed17';
//            } elseif ($power[$tg]['level'] <= 4)
//            {
//                $res['shishen']['list'][$k1]['color'] = '#00f4e7';
//            } else
//            {
//                $res['shishen']['list'][$k1]['color'] = '#00e9a0';
//            }
        }
        return $res;
    }

    /**
     * 八字择日
     * @param array $option
     *  tid int 事项ID
     *  recode array 档案信息
     *  bazi array 本命八字
     *  start_time int 需要计算的开始时间
     *  end_time int 需要计算的结束时间
     */
    public function bazizeri($option = [])
    {
        $res = ['jiri' => [], 'jishi' => []];
        $startTime = $option['start_time'];
        $endTime = $option['end_time'];
        $dayNum = ($endTime - $startTime) / 86400;
        $Horoscope = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0]);
        $bazi = $Horoscope->data['bazi'];
        $this->setHoroscopeInstance($Horoscope);
        $this->setBazi($bazi);
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        // 开始计算每一天的流日信息
        $liuriList = $Horoscope->getLiuri($startTime, $dayNum);
        foreach ($liuriList as $date => $ganzhi)
        {
            $liuri = $ganzhi['liuri'];
            $liunian = $ganzhi['liunian'];
            $liuyue = $ganzhi['liuyue'];
            /**
             * 八字
             * 亲和项
             * 1、流日不与本命冲
             * 2、流日与本命拱合且无冲，或流日与日干支拱合
             * 3、流日与本命拱合且无刑冲穿，或流日与日干支合
             * 4、流日与日干支拱合且与本命无刑冲穿
             * 吉事项务必满足一条，优先取4，结果无或太少则取3、2、1顺次
             */
            $isGongMing = $isHeMing = $isXingMing = $isChongMing = $isChuanMing = false;
            foreach ($dizhi as $k1 => $v1)
            {
                if (!$isXingMing && $Horoscope->is_xing($liuri[1], $v1))
                {
                    $isXingMing = true;
                }
                if (!$isChongMing && $Horoscope->is_liuchong($liuri[1], $v1))
                {
                    $isChongMing = true;
                }
                if (!$isChuanMing && $Horoscope->is_liuhai($liuri[1], $v1))
                {
                    $isChuanMing = true;
                }
                if (!$isGongMing && $Horoscope->is_gong($liuri[1], $v1))
                {
                    $isGongMing = true;
                }
                if (!$isHeMing && ($Horoscope->is_liuhe($liuri[1], $v1) || $Horoscope->is_anhe($liuri[1], $v1)))
                {
                    $isHeMing = true;
                }
            }
            // 初始化当天亲和为0
            $qinhe = 0;
            // 4、流日与日干支拱合且与本命无刑冲穿
            if (!$isXingMing && !$isChongMing && !$isChuanMing
                && ($Horoscope->is_wuhe($liuri[0], $tiangan[2])
                    || $Horoscope->is_gong($liuri[1], $dizhi[2])
                    || $Horoscope->is_liuhe($liuri[1], $dizhi[2])
                    || $Horoscope->is_anhe($liuri[1], $dizhi[2])))
            {
                $qinhe = 4;
            } //  3、流日与本命拱合且无刑冲穿，或流日与日干支合
            elseif ((($isGongMing || $isHeMing)
                    && !$isXingMing && !$isChongMing && !$isChuanMing)
                || ($Horoscope->is_wuhe($liuri[0], $tiangan[2])
                    || $Horoscope->is_liuhe($liuri[1], $dizhi[2])
                    || $Horoscope->is_anhe($liuri[1], $dizhi[2])))
            {
                $qinhe = 3;
            } // 流日与本命拱合且无冲，或流日与日干支拱合
            elseif ((($isGongMing || $isHeMing) && !$isChongMing)
                || ($Horoscope->is_wuhe($liuri[0], $tiangan[2])
                    || $Horoscope->is_gong($liuri[1], $dizhi[2])
                    || $Horoscope->is_liuhe($liuri[1], $dizhi[2])
                    || $Horoscope->is_anhe($liuri[1], $dizhi[2])))
            {
                $qinhe = 2;
            } // 1、流日不与本命冲
            elseif (!$isChongMing)
            {
                $qinhe = 1;
            }
            // 计算流日其他信息
            $other = $this->getZeriShixiang($option['tid'], $bazi, $ganzhi, $option['recode'], $date);
            /**
             * 满足亲和、满足其他条件
             */
            if ($qinhe > 0 && $other)
            {
                $res['jiri'][] = $date;
                /**
                 * 吉时
                 * 去掉亥子丑寅四个时辰，其它八时辰中取符合以下条件的：
                 * 1，时支与流年月日支无冲
                 * 2，时支与流年月日支拱合或时干为官印食财才
                 * 3，多则取前三个，无则取仅符合第一个条件的第一个时辰
                 */
                $zhiList = ['卯', '辰', '巳', '午', '未', '申', '酉', '戌'];
                $res['jishi'][$date] = [];
                $t = $t1 = $t2 = $t3 = [];
                foreach ($zhiList as $zhi)
                {
                    $shigan = $Horoscope->getShiGan($liuri[0], $zhi);
                    $x1 = $x2 = false;
                    if (!$Horoscope->is_liuchong($zhi, $liuri[1])
                        && !$Horoscope->is_liuchong($zhi, $liuyue[1])
                        && !$Horoscope->is_liuchong($zhi, $liunian[1]))
                    {
                        $x1 = true;
                        $t1[] = $zhi;
                    }
                    if ($Horoscope->is_gong($zhi, $liuri[1])
                        || $Horoscope->is_gong($zhi, $liuyue[1])
                        || $Horoscope->is_gong($zhi, $liunian[1])
                        || $Horoscope->is_liuhe($zhi, $liuri[1])
                        || $Horoscope->is_liuhe($zhi, $liuyue[1])
                        || $Horoscope->is_liuhe($zhi, $liunian[1])
                        || $Horoscope->is_anhe($zhi, $liuri[1])
                        || $Horoscope->is_anhe($zhi, $liuyue[1])
                        || $Horoscope->is_anhe($zhi, $liunian[1])
                        || in_array($Horoscope->param['shishen'][$shigan][$bazi[5]], ['正财', '偏财', '正官', '正印', '食神'], true))
                    {
                        $x2 = true;
                        $t2[] = $zhi;
                    }
                    if ($x1 && $x2)
                    {
                        $t3[] = $zhi;
                    }
                }
                $ct = count($t3);
                if ($ct > 3)
                {
                    $t = array_slice($t3, 0, 3);
                } elseif ($ct === 0)
                {
                    $t = array_pop($t1);
                } else
                {
                    $t = $t3;
                }
                $res['jishi'][$date] = $t;
            }
        }
        return $res;
    }

    /**
     * 获取当前择时事项
     *  月相：从太阳的度数逆时针数到月亮的度数
     *    90度之内 新月 0
     *    90-160 上弦 1
     *    160-200 满月 2
     *    200-270 下弦月 3
     *    270-360 残月 4
     * @param int $tid 择日事项
     * @param array $bazi 本命八字 1～8
     * @param array $liuriList 流日干支
     * @param array $record 档案信息
     * @param string $date 日期
     * @return bool
     */
    protected function getZeriShixiang($tid = 0, $bazi = [], $liuriList = [], $record = [], $date = '')
    {
        $res = true;
        $liuri = $liuriList['liuri'];
        $liuyue = $liuriList['liuyue'];
        $liunian = $liuriList['liunian'];
        $time = strtotime($date . ' 12:00:00');
        // 获取行运盘数据
        $advanceInfo = [
            'year' => (int)date('Y', $time),
            'month' => (int)date('n', $time),
            'day' => (int)date('d', $time),
            'hour' => (int)date('H', $time),
            'minute' => (int)date('i', $time),
            'timezone' => 8,
            'is_summer' => 0,
        ];
        $astro = Astrolog::getInstance()
            ->setRecode1($record)
            ->setAdvance($advanceInfo)
            ->setExecPrefix(config('astrolog.prefix'))
            ->setIsAstrolabe(false)
            ->setUserSetting(config('astroset.setting1'))
            ->setGetDatas(['now', 'transits', 'thirdprogressed'])
            ->getAstroDatas();
        $now = $astro->getDatas('now');
        $transits = $astro->getDatas('transits');
        $thirdprogressed = $astro->getDatas('thirdprogressed');
        $revive_day = [];
        // 需要判断日运某某之日的事项 20 21 22
        if (in_array($tid, [20, 21, 22], true))
        {
            // 开始获取日运某某之日信息
            $dailyFortune = new FortuneIndex();
            $dailyFortune->astro = $astro;
            $dailyFortune->astro
                ->setGetDatas(['now', 'natal'])
                ->getAstroDatas();

            $dailyFortune->nowData = $now;
            $dailyFortune->natalData = $dailyFortune->astro->getDatas('natal');
            $dailyFortune->transitsData = $transits;
            $dailyFortune->thirdprogressedData = $thirdprogressed;
            $dailyFortune->active = $dailyFortune->getActive();
            $revive_day = $dailyFortune->getTopic($record, $time, false);
        }
        // 命局天干
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        // 命局地支
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];

        $HoroscopeInstance = Horoscope::getInstance();

        $tids = [
            1 => '妆扮',
            2 => '购物',
            3 => '出行',
            4 => '聚餐',
            5 => '下厨',
            6 => '美容',
            7 => '减肥',
            8 => '撸猫',
            9 => '遛狗',
            10 => '游戏',
            11 => '健身',
            12 => '占卜',
            13 => '就医',
            14 => '观星',
            15 => '冥想',
            16 => '装修',
            17 => '入宅',
            18 => '搬迁',
            19 => '置家具',
            20 => '告白',
            21 => '送礼物',
            22 => '约会',
            23 => '定亲',
            24 => '领证',
            25 => '婚礼',
            26 => '开业',
            27 => '交易',
            28 => '签约',
            29 => '面试',
            30 => '入职',
            31 => '离职',
            32 => '汇报',
            33 => '立项',
            34 => '团建',
            35 => '结婚',
            36 => '买房',
        ];
        /**
         * property int 性质 0=>无,1=>中,2=>吉
         * planets array 行运星体ID
         */
        $op = [];
        switch ($tid)
        {
            case 1:
                /**
                 * 妆扮 1
                 * 性质：中
                 * 取用十神：该日含丙丁辛巳午酉且与本命日时有拱合即可
                 * 取用宫位：
                 * 取用星(行运)：金
                 * 月相（天象）：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 1;
                if ((in_array($liuri[0], ['丙', '丁', '辛'], true)
                        && ($HoroscopeInstance->is_wuhe($liuri[0], $tiangan[2])
                            || $HoroscopeInstance->is_wuhe($liuri[0], $tiangan[3])))
                    || (in_array($liuri[1], ['巳', '午', '酉'], true)
                        && ($HoroscopeInstance->is_liuhe($liuri[1], $dizhi[2])
                            || $HoroscopeInstance->is_liuhe($liuri[1], $dizhi[2])
                            || $HoroscopeInstance->is_anhe($liuri[1], $dizhi[3])
                            || $HoroscopeInstance->is_anhe($liuri[1], $dizhi[3])
                            || $HoroscopeInstance->is_gong($liuri[1], $dizhi[2])
                            || $HoroscopeInstance->is_gong($liuri[1], $dizhi[3])
                        )
                    ))
                {
                    $op['other'] = true;
                } else
                {
                    $op['other'] = false;
                }
                $op['planets'] = [3];
                break;
            case 2:
                /**
                 * 购物 2
                 * 性质：中
                 * 取用十神：才财
                 * 取用宫位：
                 * 取用星：金
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 1;
                $op['shishen'] = ['正财', '偏财'];
                $op['planets'] = [3];
                break;
            case 3:
                /**
                 * 出行 3
                 * 性质：中
                 * 取用十神：
                 * 取用宫位：
                 * 取用星：水
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：流日干支冲原局地支，或合原局印枭，且流日干支本气非七杀
                 */
                $op['property'] = 1;
                $op['planets'] = [2];
                $zhengyinGan = $this->shishens[$tiangan[2]]['正印'];
                $pianyinGan = $this->shishens[$tiangan[2]]['偏印'];
                $qishaGan = $this->shishens[$tiangan[2]]['七杀'];

                if ($liuri[0] !== $qishaGan
                    && $HoroscopeInstance->param['canggan'][$liuri[1]][0] !== $qishaGan
                    && (
                        $HoroscopeInstance->is_liuchong($liuri[1], $dizhi[0])
                        || $HoroscopeInstance->is_liuchong($liuri[1], $dizhi[1])
                        || $HoroscopeInstance->is_liuchong($liuri[1], $dizhi[2])
                        || $HoroscopeInstance->is_liuchong($liuri[1], $dizhi[3])
                        || $HoroscopeInstance->is_wuhe($liuri[0], $zhengyinGan)
                        || $HoroscopeInstance->is_wuhe($liuri[0], $pianyinGan)))
                {
                    $op['other'] = true;
                }
                break;
            case 4:
                /**
                 * 聚餐 4
                 * 性质：吉
                 * 取用十神：食神
                 * 取用宫位：
                 * 取用星：水金日月木
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['食神'];
                $op['planets'] = [0, 1, 2, 3, 5];
                break;
            case 5:
                /**
                 * 下厨 5
                 * 性质：中
                 * 取用十神：食神
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：行运日月金水与原局火或土成非刑冲相
                 */
                $op['property'] = 1;
                $op['shishen'] = ['食神'];
                $other = false;
                if ((isset($transits[1]['planets'][0]['phase']['0-4'])
                        && !in_array($transits[1]['planets'][0]['phase']['0-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][0]['phase']['0-6'])
                        && !in_array($transits[1]['planets'][0]['phase']['0-6']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][1]['phase']['1-4'])
                        && !in_array($transits[1]['planets'][1]['phase']['1-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][1]['phase']['1-6'])
                        && !in_array($transits[1]['planets'][1]['phase']['1-6']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][2]['phase']['2-4'])
                        && !in_array($transits[1]['planets'][2]['phase']['2-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][2]['phase']['2-6'])
                        && !in_array($transits[1]['planets'][2]['phase']['2-6']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][3]['phase']['3-4'])
                        && !in_array($transits[1]['planets'][3]['phase']['3-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][3]['phase']['3-6'])
                        && !in_array($transits[1]['planets'][3]['phase']['3-6']['phase_e'], [90, 180], true)))
                {
                    $other = true;
                }
                $op['other'] = $other;
                break;
            case 6:
                /**
                 * 美容 6
                 * 性质：吉
                 * 取用十神：流日出现庚辛申酉同时有劫印之一，且有亲和
                 * 取用宫位：
                 * 取用星：
                 * 月相：非残月
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [0, 1, 2, 3];
                // 流日出现庚辛申酉同时有劫印之一，且有亲和
                $op['other'] = false;
                if ((in_array($liuri[0], ['庚', '辛'], true)
                        || in_array($liuri[1], ['申', '酉'], true))
                    && ($this->shishens[$tiangan[2]]['劫财'] === $liuri[0]
                        || $this->shishens[$tiangan[2]]['正印'] === $liuri[0]
                        || $this->shishens[$tiangan[2]]['劫财'] === $HoroscopeInstance->param['canggan'][$liuri[1]][0]
                        || $this->shishens[$tiangan[2]]['正印'] === $HoroscopeInstance->param['canggan'][$liuri[1]][0]))
                {
                    $qinhe = $this->qinheLevel($liuri);
                    if ($qinhe <= 5)
                    {
                        $op['other'] = true;
                    }
                }
                break;
            case 7:
                /**
                 * 减肥 7
                 * 性质：吉
                 * 取用十神：枭神
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：火土
                 * 其他条件：行运日月金水与原局土星成相位
                 */
                $op['property'] = 2;
                $op['shishen'] = ['偏印'];
                $op['moon_shunna'] = [4, 6];
                if (isset($transits[1]['planets'][0]['phase']['0-6'])
                    || isset($transits[1]['planets'][1]['phase']['1-6'])
                    || isset($transits[1]['planets'][2]['phase']['2-6'])
                    || isset($transits[1]['planets'][3]['phase']['3-6']))
                {
                    $op['other'] = true;
                } else
                {
                    $op['other'] = false;
                }
                break;
            case 8:
                /**
                 * 撸猫 8
                 * 性质：吉
                 * 取用十神：食神伤官
                 * 取用宫位：时柱子女宫
                 * 取用星：金
                 * 月相：
                 * 月亮顺纳：日金木海
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['偏印'];
                $op['gong'] = ['gan' => $bazi[7], 'zhi' => $bazi[8], 'xing' => [], 'dai' => []];
                $op['planets'] = [3];
                $op['moon_shunna'] = [0, 3, 5, 8];
                break;
            case 9:
                /**
                 * 遛狗 9
                 * 性质：
                 * 取用十神：
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                break;
            case 10:
                /**
                 * 游戏 10
                 * 性质：
                 * 取用十神：食神伤官
                 * 取用宫位：
                 * 取用星：日金
                 * 月相：
                 * 月亮顺纳：日金木海
                 * 其他条件：行运日月金水火之一在5宫，或与5宫内星成相
                 */
                $op['property'] = 0;
                $op['shishen'] = ['十神', '伤官'];
                $op['planets'] = [0, 3];
                $op['moon_shunna'] = [0, 3, 5, 8];
                $ps = [0, 1, 2, 3, 4];
                $other = false;
                foreach ($ps as $p)
                {
                    if ($transits[1]['planets'][$p]['in_house_id'] === 5)
                    {
                        $other = true;
                        break;
                    }
                    if (!empty($transits[1]['planets'][$p]['phase']))
                    {
                        foreach ($transits[1]['planets'][$p]['phase'] as $phase)
                        {
                            if ($phase['id'] < 10 && $transits[1]['planets'][$phase['id']]['in_house_id'] === 5)
                            {
                                $other = true;
                                break 2;
                            }
                        }
                    }
                }
                $op['other'] = $other;
                break;
            case 11:
                /**
                 * 健身 11
                 * 性质：吉
                 * 取用十神：比肩劫财
                 * 取用宫位：
                 * 取用星：火
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：行运日月金水火与原局火或土成非刑冲相
                 */
                $op['property'] = 2;
                $op['shishen'] = ['比肩', '劫财'];
                $op['planets'] = [4];
                $op['moon_shunna'] = [0, 3, 5, 8];
                $other = false;
                if ((isset($transits[1]['planets'][0]['phase']['0-4'])
                        && !in_array($transits[1]['planets'][0]['phase']['0-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][0]['phase']['0-6'])
                        && !in_array($transits[1]['planets'][0]['phase']['0-6']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][1]['phase']['1-4'])
                        && !in_array($transits[1]['planets'][1]['phase']['1-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][1]['phase']['1-6'])
                        && !in_array($transits[1]['planets'][1]['phase']['1-6']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][2]['phase']['2-4'])
                        && !in_array($transits[1]['planets'][2]['phase']['2-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][2]['phase']['2-6'])
                        && !in_array($transits[1]['planets'][2]['phase']['2-6']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][3]['phase']['3-4'])
                        && !in_array($transits[1]['planets'][3]['phase']['3-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][3]['phase']['3-6'])
                        && !in_array($transits[1]['planets'][3]['phase']['3-6']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][4]['phase']['4-4'])
                        && !in_array($transits[1]['planets'][4]['phase']['4-4']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][4]['phase']['4-6'])
                        && !in_array($transits[1]['planets'][4]['phase']['4-6']['phase_e'], [90, 180], true)))
                {
                    $other = true;
                }
                $op['other'] = $other;
                break;
            case 12:
                /**
                 * 占卜 12
                 * 性质：
                 * 取用十神：伤枭
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：行运日月金水火与原局海王或木星成非刑冲相
                 */
                $op['property'] = 0;
                $op['shishen'] = ['伤官', '偏印'];
                $other = false;
                if ((isset($transits[1]['planets'][0]['phase']['0-5'])
                        && !in_array($transits[1]['planets'][0]['phase']['0-5']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][0]['phase']['0-8'])
                        && !in_array($transits[1]['planets'][0]['phase']['0-8']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][1]['phase']['1-5'])
                        && !in_array($transits[1]['planets'][1]['phase']['1-5']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][1]['phase']['1-8'])
                        && !in_array($transits[1]['planets'][1]['phase']['1-8']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][2]['phase']['2-5'])
                        && !in_array($transits[1]['planets'][2]['phase']['2-5']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][2]['phase']['2-8'])
                        && !in_array($transits[1]['planets'][2]['phase']['2-8']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][3]['phase']['3-5'])
                        && !in_array($transits[1]['planets'][3]['phase']['3-5']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][3]['phase']['3-8'])
                        && !in_array($transits[1]['planets'][3]['phase']['3-8']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][4]['phase']['4-5'])
                        && !in_array($transits[1]['planets'][4]['phase']['4-5']['phase_e'], [90, 180], true))
                    || (isset($transits[1]['planets'][4]['phase']['4-8'])
                        && !in_array($transits[1]['planets'][4]['phase']['4-8']['phase_e'], [90, 180], true)))
                {
                    $other = true;
                }
                $op['other'] = $other;
                break;
            case 13:
                /**
                 * 就医 13
                 * 性质：吉
                 * 取用十神：食印
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：火土冥海
                 * 其他条件：行运日月金水火与原局海王或木星成非刑相
                 */
                $op['property'] = 2;
                $op['shishen'] = ['食神', '正印'];
                $op['moon_shunna'] = [4, 6, 8, 9];
                $other = false;
                if ((isset($transits[1]['planets'][0]['phase']['0-4'])
                        && $transits[1]['planets'][0]['phase']['0-4']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][0]['phase']['0-6'])
                        && $transits[1]['planets'][0]['phase']['0-6']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][1]['phase']['1-4'])
                        && $transits[1]['planets'][1]['phase']['1-4']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][1]['phase']['1-6'])
                        && $transits[1]['planets'][1]['phase']['1-6']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][2]['phase']['2-4'])
                        && $transits[1]['planets'][2]['phase']['2-4']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][2]['phase']['2-6'])
                        && $transits[1]['planets'][2]['phase']['2-6']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][3]['phase']['3-4'])
                        && $transits[1]['planets'][3]['phase']['3-4']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][3]['phase']['3-6'])
                        && $transits[1]['planets'][3]['phase']['3-6']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][4]['phase']['4-4'])
                        && $transits[1]['planets'][4]['phase']['4-4']['phase_e'] !== 90)
                    || (isset($transits[1]['planets'][4]['phase']['4-6'])
                        && $transits[1]['planets'][4]['phase']['4-6']['phase_e'] !== 90))
                {
                    $other = true;
                }
                $op['other'] = $other;
                break;
            case 14:
                /**
                 * 观星 14
                 * 性质：
                 * 取用十神：
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */

                break;
            case 15:
                /**
                 * 冥想 15
                 * 性质：
                 * 取用十神：枭印
                 * 取用宫位：
                 * 取用星：
                 * 月相：新月
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 0;
                $op['shishen'] = ['正印', '偏印'];
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [0];
                break;
            case 16:
                /**
                 * 装修 16
                 * 性质：吉
                 * 取用十神：才财印枭
                 * 取用宫位：夫妻宫或子女宫
                 * 取用星：金月
                 * 月相：非下弦月残月
                 * 月亮顺纳：日火木天
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正财', '偏财', '正印', '偏印'];
                $op['gong'] = [
                    'gan' => '',
                    'zhi' => $bazi[6],
                    'xing' => [],
                    'dai' => [
                        'gan' => $bazi[7],
                        'zhi' => $bazi[8],
                        'xing' => []
                    ],
                ];
                $op['planets'] = [1, 3];
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [0, 1, 2];
                $op['moon_shunna'] = [0, 4, 5, 7];
                break;
            case 17:
                /**
                 * 入宅 17 同搬迁、移除
                 * 性质：
                 * 取用十神：
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                break;
            case 18:
                /**
                 * 搬迁 18
                 * 性质：吉
                 * 取用十神：禄印
                 * 取用宫位：夫妻宫（日支）
                 * 取用星：金月
                 * 月相：非下弦月残月
                 * 月亮顺纳：水火木
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['禄神', '正印'];
//                $op['gong'] = [
//                    'gan' => '',
//                    'zhi' => $bazi[6],
//                    'xing' => [],
//                    'dai' => [],
//                ];
                $op['planets'] = [1, 3];
//                // 新月0,上弦1,满月2,下弦月3,残月4
//                $op['moon_phase'] = [0, 1, 2];
//                $op['moon_shunna'] = [2, 4, 5];
                break;
            case 19:
                /**
                 * 置家具 19
                 * 性质：吉
                 * 取用十神：财才与印枭同动
                 * 取用宫位：时柱子女宫或日支夫妻宫
                 * 取用星：金月
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正财', '偏财', '正印', '偏印'];
                $op['gong'] = [
                    'gan' => '',
                    'zhi' => $bazi[6],
                    'xing' => [],
                    'dai' => [
                        'gan' => $bazi[7],
                        'zhi' => $bazi[8],
                        'xing' => []
                    ],
                ];
                $op['planets'] = [1, 3];
                // 财才与印枭同动
                $cai = $this->zhuti('', '', ['正财', '偏财'], $liuri, [], 1);
                $yin = $this->zhuti('', '', ['正印', '偏印'], $liuri, [], 1);
                if ($cai['xing_dongtai'] > 0 && $yin['xing_dongtai'] > 0)
                {
                    $op['other'] = true;
                } else
                {
                    $op['other'] = false;
                }
                break;
            case 20:
                /**
                 * 告白 20
                 * 性质：吉
                 * 取用十神：食神
                 * 取用宫位：夫妻宫，夫妻星可代
                 * 取用星：水日月
                 * 月相：新月、上弦
                 * 月亮顺纳：日金水火木海
                 * 其他条件：日运如为粉红、桃花日可免一切条件
                 */
                $op['property'] = 2;
                $other = false;
                if (!empty($revive_day))
                {
                    foreach ($revive_day as $rd)
                    {
                        if ($rd['name'] === '粉红之日' || $rd['name'] === '桃花之日')
                        {
                            $other = true;
                            $op['other'] = $other;
                            break;
                        }
                    }
                }
                if (!$other)
                {
                    $op['shishen'] = ['食神'];
                    $op['gong'] = [
                        'gan' => '',
                        'zhi' => $bazi[6],
                        'xing' => [],
                        'dai' => [
                            'gan' => '',
                            'zhi' => '',
                            'xing' => []
                        ],
                    ];
                    // 夫妻星 男才财女官杀
                    if ((int)$record['type'] === 1)
                    {
                        $op['gong']['dai']['xing'] = ['正财', '偏财'];
                    } else
                    {
                        $op['gong']['dai']['xing'] = ['正官', '七杀'];
                    }
//                    $op['planets'] = [1, 3];
//                    // 新月0,上弦1,满月2,下弦月3,残月4
//                    $op['moon_phase'] = [0, 1, 2];
//                    $op['moon_shunna'] = [0, 2, 3, 4, 5, 8];
                }
                break;
            case 21:
                /**
                 * 送礼物 21
                 * 性质：吉
                 * 取用十神：才财
                 * 取用宫位：夫妻宫，夫妻星可代
                 * 取用星：水金日月
                 * 月相：
                 * 月亮顺纳：日金水火木海
                 * 其他条件：日运如为粉红、桃花日可免一切条件
                 */
                $op['property'] = 2;
                $other = false;
                if (!empty($revive_day))
                {
                    foreach ($revive_day as $rd)
                    {
                        if ($rd['name'] === '粉红之日' || $rd['name'] === '桃花之日')
                        {
                            $other = true;
                            $op['other'] = $other;
                            break;
                        }
                    }
                }
                if (!$other)
                {
                    $op['shishen'] = ['正财', '偏财'];
                    $op['gong'] = [
                        'gan' => '',
                        'zhi' => $bazi[6],
                        'xing' => [],
                        'dai' => [
                            'gan' => '',
                            'zhi' => '',
                            'xing' => []
                        ],
                    ];
                    // 夫妻星 男才财女官杀
                    if ((int)$record['type'] === 1)
                    {
                        $op['gong']['dai']['xing'] = ['正财', '偏财'];
                    } else
                    {
                        $op['gong']['dai']['xing'] = ['正官', '七杀'];
                    }
                    $op['planets'] = [0, 1, 2, 3];
                    $op['moon_shunna'] = [0, 2, 3, 4, 5, 8];
                }
                break;
            case 22:
                /**
                 * 约会 22
                 * 性质：吉
                 * 取用十神：男才财女官杀
                 * 取用宫位：夫妻宫，日干支合本命日时可代
                 * 取用星：水金日月
                 * 月相：
                 * 月亮顺纳：日金水火木海
                 * 其他条件：日运如为粉红、桃花日可免一切条件
                 */
                $op['property'] = 2;
                $other = false;
                if (!empty($revive_day))
                {
                    foreach ($revive_day as $rd)
                    {
                        if ($rd['name'] === '粉红之日' || $rd['name'] === '桃花之日')
                        {
                            $other = true;
                            $op['other'] = $other;
                            break;
                        }
                    }
                }
                if (!$other)
                {
                    // 日干支合本命日时可代
                    if ($HoroscopeInstance->is_wuhe($liuri[0], $tiangan[2])
                        || $HoroscopeInstance->is_wuhe($liuri[0], $tiangan[3])
                        || $HoroscopeInstance->is_liuhe($liuri[1], $dizhi[2])
                        || $HoroscopeInstance->is_liuhe($liuri[1], $dizhi[3])
                        || $HoroscopeInstance->is_anhe($liuri[1], $dizhi[2])
                        || $HoroscopeInstance->is_anhe($liuri[1], $dizhi[3]))
                    {
                        $op['other'] = true;
                    } else
                    {
                        $op['gong'] = [
                            'gan' => '',
                            'zhi' => $bazi[6],
                            'xing' => [],
                            'dai' => [],
                        ];
                    }
                    $op['planets'] = [0, 1, 2, 3];
                    $op['moon_shunna'] = [0, 2, 3, 4, 5, 8];
                }
                break;
            case 23:
                /**
                 * 定亲 23
                 * 性质：吉
                 * 取用十神：枭印
                 * 取用宫位：夫妻宫，夫妻星可代
                 * 取用星：水金日月
                 * 月相：新月
                 * 月亮顺纳：日金水火木
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正印', '偏印'];
                $op['gong'] = [
                    'gan' => '',
                    'zhi' => $bazi[6],
                    'xing' => [],
                    'dai' => [
                        'gan' => '',
                        'zhi' => '',
                        'xing' => []
                    ],
                ];
                // 夫妻星 男才财女官杀
                if ((int)$record['type'] === 1)
                {
                    $op['gong']['dai']['xing'] = ['正财', '偏财'];
                } else
                {
                    $op['gong']['dai']['xing'] = ['正官', '七杀'];
                }
//                $op['planets'] = [0, 1, 2, 3];
//                // 新月0,上弦1,满月2,下弦月3,残月4
//                $op['moon_phase'] = [0];
//                $op['moon_shunna'] = [0, 2, 3, 4, 5];
                break;
            case 24:
                /**
                 * 领证 24
                 * 性质：吉
                 * 取用十神：枭印
                 * 取用宫位：夫妻宫，夫妻星可代
                 * 取用星：水金日月
                 * 月相：上弦，满月
                 * 月亮顺纳：日金水火木
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正印', '偏印'];
                $op['gong'] = [
                    'gan' => '',
                    'zhi' => $bazi[6],
                    'xing' => [],
                    'dai' => [
                        'gan' => '',
                        'zhi' => '',
                        'xing' => []
                    ],
                ];
                // 夫妻星 男才财女官杀
                if ((int)$record['type'] === 1)
                {
                    $op['gong']['dai']['xing'] = ['正财', '偏财'];
                } else
                {
                    $op['gong']['dai']['xing'] = ['正官', '七杀'];
                }
                $op['planets'] = [0, 1, 2, 3];
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [1, 2];
                $op['moon_shunna'] = [0, 2, 3, 4, 5];
                break;
            case 25:
                /**
                 * 婚礼 25
                 * 性质：吉
                 * 取用十神：枭印
                 * 取用宫位：夫妻宫，夫妻星可代
                 * 取用星：水金日月木
                 * 月相：上弦，满月
                 * 月亮顺纳：金木
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正印', '偏印'];
                $op['gong'] = [
                    'gan' => '',
                    'zhi' => $bazi[6],
                    'xing' => [],
                    'dai' => [
                        'gan' => '',
                        'zhi' => '',
                        'xing' => []
                    ],
                ];
                // 夫妻星 男才财女官杀
                if ((int)$record['type'] === 1)
                {
                    $op['gong']['dai']['xing'] = ['正财', '偏财'];
                } else
                {
                    $op['gong']['dai']['xing'] = ['正官', '七杀'];
                }
                $op['planets'] = [0, 1, 2, 3, 5];
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [1, 2];
                $op['moon_shunna'] = [0, 2, 3, 4, 5];
                break;
            case 26:
                /**
                 * 开业 26
                 * 性质：吉
                 * 取用十神：才财官印
                 * 取用宫位：
                 * 取用星：金日月木
                 * 月相：非下弦月残月
                 * 月亮顺纳：日水金火木土
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正财', '偏财', '正官', '正印'];
                $op['planets'] = [0, 1, 3, 5];
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [0, 1, 2];
                $op['moon_shunna'] = [0, 2, 3, 4, 5, 6];
                break;
            case 27:
                /**
                 * 交易 27
                 * 性质：吉
                 * 取用十神：财才
                 * 取用宫位：
                 * 取用星：水金木
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正财', '偏财'];
                $op['planets'] = [2, 3, 5];
                break;
            case 28:
                /**
                 * 签约 28
                 * 性质：吉
                 * 取用十神：印枭
                 * 取用宫位：
                 * 取用星：水金
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正印', '偏印'];
                $op['planets'] = [2, 3];
                break;
            case 29:
                /**
                 * 面试 29
                 * 性质：吉
                 * 取用十神：食伤
                 * 取用宫位：
                 * 取用星：水金日月
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['食神', '伤官'];
                $op['planets'] = [0, 1, 2, 3];
                break;
            case 30:
                /**
                 * 入职 30
                 * 性质：吉
                 * 取用十神：官印
                 * 取用宫位：
                 * 取用星：日月十宫主
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['食神', '伤官'];
                $op['planets'] = [0, 1, $transits[1]['houses'][10]['protect_ancient_id']];
                break;
            case 31:
                /**
                 * 离职 31
                 * 性质：
                 * 取用十神：
                 * 取用宫位：
                 * 取用星：
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：流日支与原局冲，星盘三限月木或月天成相
                 */
                $op['property'] = 0;
                $other = false;
                if (($HoroscopeInstance->is_liuchong($liuri[1], $bazi[2])
                        || $HoroscopeInstance->is_liuchong($liuri[1], $bazi[4])
                        || $HoroscopeInstance->is_liuchong($liuri[1], $bazi[6])
                        || $HoroscopeInstance->is_liuchong($liuri[1], $bazi[8]))
                    && (isset($thirdprogressed['planets'][1]['phase']['1-5'])
                        || isset($thirdprogressed['planets'][1]['phase']['1-7'])))
                {
                    $other = true;
                }
                $op['other'] = $other;
                break;
            case 32:
                /**
                 * 汇报 32
                 * 性质：吉
                 * 取用十神：食官
                 * 取用宫位：
                 * 取用星：水金日月
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['食神', '伤官'];
                $op['planets'] = [0, 1, 2, 3];
                break;
            case 33:
                /**
                 * 立项 33
                 * 性质：吉
                 * 取用十神：才财官印食
                 * 取用宫位：
                 * 取用星：金日月木水
                 * 月相：非下弦月残月
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正财', '偏财', '正官', '正印', '食神'];
                $op['planets'] = [0, 1, 2, 3, 5];
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [0, 1, 2];
                break;
            case 34:
                /**
                 * 团建 34
                 * 性质：吉
                 * 取用十神：比劫
                 * 取用宫位：食神代
                 * 取用星：水金木
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['比肩', '劫财'];
                $op['gong'] = [
                    'gan' => '',
                    'zhi' => '',
                    'xing' => [],
                    'dai' => [
                        'gan' => '',
                        'zhi' => '',
                        'xing' => ['食神'],
                    ]
                ];
                $op['planets'] = [2, 3, 5];
                break;
            case 35:
                /**
                 * 结婚 35
                 * 性质：吉
                 * 取用十神：枭印
                 * 取用宫位：夫妻宫，夫妻星可代
                 * 取用星：水金日月木
                 * 月相：上弦，满月
                 * 月亮顺纳：金木
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正印', '偏印'];
                $op['gong'] = [
                    'gan' => '',
                    'zhi' => $bazi[6],
                    'xing' => [],
                    'dai' => [
                        'gan' => '',
                        'zhi' => '',
                        'xing' => []
                    ],
                ];
                // 夫妻星 男才财女官杀
                if ((int)$record['type'] === 1)
                {
                    $op['gong']['dai']['xing'] = ['正财', '偏财'];
                } else
                {
                    $op['gong']['dai']['xing'] = ['正官', '七杀'];
                }
                $op['planets'] = [0, 1, 2, 3, 5];
                // 新月0,上弦1,满月2,下弦月3,残月4
                $op['moon_phase'] = [1, 2];
                $op['moon_shunna'] = [3, 5];
                break;
            case 36:
                /**
                 * 买房 36
                 * 性质：吉
                 * 取用十神：枭印
                 * 取用宫位：
                 * 取用星：水金日月
                 * 月相：
                 * 月亮顺纳：
                 * 其他条件：
                 */
                $op['property'] = 2;
                $op['shishen'] = ['正印', '偏印'];
                $op['planets'] = [0, 1, 2, 3];
                break;
            default:
                $op = [];
                break;
        }
        // 开始吉日判定
        if (!empty($op))
        {
            $property = 0;
            foreach ($op as $k1 => $v1)
            {
                switch ($k1)
                {
                    case 'property':
                        $property = $v1;
                        break;
                    case 'shishen':
                        /**
                         * 星项
                         * 1、取用的吉神在流年或本命，被流日干合或支合
                         * 2、取用的吉神在流日干支出现，或在流月干支出现被流日干支拱合
                         * 所有项务必满足一条，优先2，结果无或太少则取1
                         */
                        $isShishen = false;
                        foreach ($v1 as $ss)
                        {
                            $ssG = $this->shishens[$tiangan[2]][$ss] ?? '';
                            // 取用的吉神在流日干支出现
                            if ($ssG === $liuri[0] || $ssG === $HoroscopeInstance->param['canggan'][$liuri[1]][0])
                            {
                                $isShishen = true;
                                break;
                            }
                            // 或在流月干支出现被流日干支拱合
                            if (($ssG === $liuyue[0] && $HoroscopeInstance->is_wuhe($ssG, $liuri[0]))
                                || ($ssG === $HoroscopeInstance->param['canggan'][$liuyue[1]][0] && $HoroscopeInstance->is_liuhe($liuyue[1], $liuri[1])))
                            {
                                $isShishen = true;
                                break;
                            }
                            // 取用的吉神在流年或本命，被流日干合或支合
                            if (($HoroscopeInstance->is_wuhe($ssG, $liuri[0])
                                    && ($ssG === $liunian[0]
                                        || $ssG === $tiangan[0]
                                        || $ssG === $tiangan[1]
                                        || $ssG === $tiangan[3]
                                    ))
                                || ($ssG === $HoroscopeInstance->param['canggan'][$liunian[1]][0]
                                    && ($HoroscopeInstance->is_liuhe($liunian[1], $liuri[1])
                                        || $HoroscopeInstance->is_anhe($liunian[1], $liuri[1])))
                                || ($ssG === $HoroscopeInstance->param['canggan'][$dizhi[0]][0]
                                    && ($HoroscopeInstance->is_liuhe($dizhi[0], $liuri[1])
                                        || $HoroscopeInstance->is_anhe($dizhi[0], $liuri[1])))
                                || ($ssG === $HoroscopeInstance->param['canggan'][$dizhi[1]][0]
                                    && ($HoroscopeInstance->is_liuhe($dizhi[1], $liuri[1])
                                        || $HoroscopeInstance->is_anhe($dizhi[1], $liuri[1])))
                                || ($ssG === $HoroscopeInstance->param['canggan'][$dizhi[2]][0]
                                    && ($HoroscopeInstance->is_liuhe($dizhi[2], $liuri[1])
                                        || $HoroscopeInstance->is_anhe($dizhi[2], $liuri[1])))
                                || ($ssG === $HoroscopeInstance->param['canggan'][$dizhi[3]][0]
                                    && ($HoroscopeInstance->is_liuhe($dizhi[3], $liuri[1])
                                        || $HoroscopeInstance->is_anhe($dizhi[3], $liuri[1]))))
                            {
                                $isShishen = true;
                                break;
                            }
                        }
                        if (!$isShishen)
                        {
                            $res = false;
                            break 2;
                        }
                        break;
                    case 'gong':
                        /**
                         * 宫项
                         * 夫妻宫：日支；夫妻星：男才财女官杀
                         * 1、取用的宫位在流月动态不为零且无负面值，同时被流日干支拱合
                         * 2、取用的宫位在流日动态不为零且无负面值
                         * 吉事项有宫传入时，务必满足一条，优先2，有时可用其它星项取代（看具体说明）
                         */
                        $isGong = false;
                        if ($v1['gan'] !== '' || $v1['zhi'] !== '' || !empty($v1['xing']))
                        {
                            $zhuti = $this->zhuti($v1['gan'], $v1['zhi'], $v1['xing'], $liuyue, [], 1);
                            if (($zhuti['gong_dongtai'] + $zhuti['xing_dongtai']) > 0
                                && $zhuti['gong_fumian'] <= 0
                                && $zhuti['xing_fumian'] <= 0)
                            {
//                                if (($v1['gan'] !== '' && $HoroscopeInstance->is_wuhe($v1['gan'], $liuri[0]))
//                                    || ($v1['zhi'] !== ''
//                                        && ($HoroscopeInstance->is_liuhe($v1['gan'], $liuri[0])
//                                            || $HoroscopeInstance->is_anhe($v1['gan'], $liuri[0])))
//                                )
//                                {
//                                    $isGong = true;
//                                }
                                $isGong = true;
                            }
                        }
                        if (!$isGong && !empty($v1['dai']))
                        {
                            $zhuti = $this->zhuti($v1['dai']['gan'], $v1['dai']['zhi'], $v1['dai']['xing'], $liuyue, [], 1);
                            if (($zhuti['gong_dongtai'] + $zhuti['xing_dongtai']) > 0
                                && $zhuti['gong_fumian'] <= 0
                                && $zhuti['xing_fumian'] <= 0)
                            {
//                                if (($v1['gan'] !== '' && $HoroscopeInstance->is_wuhe($v1['gan'], $liuri[0]))
//                                    || ($v1['zhi'] !== ''
//                                        && ($HoroscopeInstance->is_liuhe($v1['gan'], $liuri[0])
//                                            || $HoroscopeInstance->is_anhe($v1['gan'], $liuri[0])))
//                                )
//                                {
//                                    $isGong = true;
//                                }
                                $isGong = true;
                            }
                        }
                        if (!$isGong)
                        {
                            $res = false;
                            break 2;
                        }
                        break;
                    case 'planets':
                        /**
                         * 行运项
                         * 1、取用星无凶象引动
                         * 2、取用星有非凶象引动
                         * 3、取用星有吉象引动
                         * 吉事项务必满足一条，先3后2后1
                         * 4、取用星有任意引动
                         * 中性事项如无说明均满足此条。注意，行运所涉相位仅包括行运星为日水金火的相位
                         */
                        $isPlanets = false;
                        if (!empty($v1))
                        {
                            $state1 = 0;
                            $state2 = 0;
                            $state3 = 0;
                            foreach ($v1 as $pid)
                            {
                                if (!empty($transits[1]['planets'][$pid]['phase']))
                                {
                                    foreach ($transits[1]['planets'][$pid]['phase'] as $phase)
                                    {
                                        if ($phase['id'] < 10)
                                        {
                                            // 取用星有吉象引动
                                            if (in_array($phase['phase_e'], [0, 60, 120], true) && !in_array($phase['id'], [4, 6, 8, 9], true))
                                            {
                                                $state1 = 1;
                                            } // 取用星有非凶象引动
                                            elseif (!in_array($phase['phase_e'], [90, 180], true) && !in_array($phase['id'], [4, 6, 8, 9], true))
                                            {
                                                $state2 = 1;
                                            } else
                                            {
                                                $state3 = 1;
                                            }
                                        }
                                    }
                                }
                            }
                            // 吉事项务必满足一条，先3后2后1
                            if ($property === 2 && !$state1 && !$state2 && !$state3)
                            {
                                $res = false;
                                break 2;
                            }
                            // 中性事项如无说明均满足此条 取用星有任意引动
                            if ($property === 1 && !$state1 && !$state2 && !$state3)
                            {
                                $res = false;
                                break 2;
                            }
                        }
                        break;
                    case 'moon_phase':
                        // 月相：从太阳的度数逆时针数到月亮的度数
                        //90度之内 新月 0
                        //90-160 上弦 1
                        //160-200 满月 2
                        //200-270 下弦月 3
                        //270-360 残月 4
                        $moonDeg = $transits[1]['planets'][1]['deg'];
                        $sunDeg = $transits[1]['planets'][0]['deg'];
                        $diff = $moonDeg - $sunDeg;
                        if ($diff < 0)
                        {
                            $diff += 360;
                        }
                        if ($diff <= 90)
                        {
                            $moonState = 0;
                        } elseif ($diff <= 160)
                        {
                            $moonState = 1;
                        } elseif ($diff <= 200)
                        {
                            $moonState = 2;
                        } elseif ($diff <= 270)
                        {
                            $moonState = 3;
                        } else
                        {
                            $moonState = 4;
                        }
                        if (!in_array($moonState, $v1, true))
                        {
                            $res = false;
                            break 2;
                        }
                        break;
                    case 'moon_shunna':
                        // 月亮顺纳 合供六分相吗
                        $isShunna = false;
                        foreach ($v1 as $p)
                        {
                            $key = '1-' . $p;
                            if (isset($now['planets'][1]['phase'][$key])
                                && in_array($now['planets'][1]['phase'][$key]['phase_e'], [0, 60, 120], true))
                            {
                                $isShunna = true;
                                break;
                            }
                        }
                        if (!$isShunna)
                        {
                            $res = false;
                            break 2;
                        }
                        break;
                }
            }
        }

        return $res;
    }

    /**
     * 计算八字用神信息
     * @param array $option
     *  good_years array 最好的年份
     *  bad_years array 最差的年份
     * @return array
     */
    public function baziyongshen($option = [])
    {
        $res = [
            'yongshen' => '',
            'fangxiang' => '',
            'yanse' => '',
            'quming' => '',
            // 旺衰用神
            'wangshuai' => [
                'title' => '旺衰用神',
                'tag_list' => [],
                'content' => '旺衰法是计算日主的力量强弱，认为力量强的人更容易发挥才干获取财官，而力量弱的人则需要补足力量。',
            ],
            // 调候用神
            'diaohou' => [
                'title' => '调候用神',
                'tag_list' => [],
                'content' => '调候法就是计算你出生时的季节气候，用五行来补足气候的不足，给你创造更好的生长环境。',
            ],
            // 病药用神
            'bingyao' => [
                'title' => '病药用神',
                'tag_list' => [],
                'content' => '病药法是寻找八字当中的问题（病），针对性的寻求解决问题的字或五行（药）。',
            ],
            // 格局用神
            'geju' => [
                'title' => '格局用神',
                'tag_list' => [],
                'content' => '',
            ],
            // 用神整合
            'yongshenzhenghe' => [
                'tiangan' => [
                    '甲' => 0,
                    '乙' => 0,
                    '丙' => 0,
                    '丁' => 0,
                    '戊' => 0,
                    '己' => 0,
                    '庚' => 0,
                    '辛' => 0,
                    '壬' => 0,
                    '癸' => 0,
                ],
                'dizhi' => [
                    '子' => 0,
                    '丑' => 0,
                    '寅' => 0,
                    '卯' => 0,
                    '辰' => 0,
                    '巳' => 0,
                    '午' => 0,
                    '未' => 0,
                    '申' => 0,
                    '酉' => 0,
                    '戌' => 0,
                    '亥' => 0
                ],
            ],
        ];
        $yongshenFen = [
            'tiangan' => [
                '甲' => 0,
                '乙' => 0,
                '丙' => 0,
                '丁' => 0,
                '戊' => 0,
                '己' => 0,
                '庚' => 0,
                '辛' => 0,
                '壬' => 0,
                '癸' => 0,
            ],
            'dizhi' => [
                '子' => 0,
                '丑' => 0,
                '寅' => 0,
                '卯' => 0,
                '辰' => 0,
                '巳' => 0,
                '午' => 0,
                '未' => 0,
                '申' => 0,
                '酉' => 0,
                '戌' => 0,
                '亥' => 0
            ],
        ];
        $advance = [
            'year' => date('Y') * 1,
            'month' => date('m') * 1,
            'day' => date('d') * 1,
            'hour' => date('H') * 1,
            'minute' => date('i') * 1,
            'timezone' => 8,
            'is_summer' => 0,
        ];
        $Horoscope = Horoscope::getInstance(['recode' => $this->record, 'time_start' => 23, 'time_type' => 0, 'advance' => $advance]);
        $bazi = $Horoscope->data['bazi'];
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        /**
         * 旺衰
         * 以下12拼接
         * 旺衰判定：
         *   日干全无根气 从弱
         *   日干有根气
         *      本气根10，印本气根3，枭本气根3，非本气根3
         *      本气根在月令+3
         *      根在年支-1
         *      天干比劫、正印3，偏印2
         *      按以上分数加减，求得日干得分
         *          13分及其以上，身强
         *          30分及以上，从强
         *          13分以下，身弱
         *          3分及以下，且日干为阴干，从弱
         * 1、旺衰法是计算日主的力量强弱，认为力量强的人更容易发挥才干获取财官，而力量弱的人则需要补足力量。
         * 2、你的日主处于
         *   身旺状态，可以胜任财官，喜欢跟自己相克、消耗自己力量的五行，用神为 【金、土、火】（取官杀财才食伤）
         *   身弱状态，优先补足力量，喜欢生自己和扶持自己的五行，用神为【水、木】（取印枭比劫）
         *   从旺状态，力量过于强旺，此时只宜生不宜克，用神为【水、木、火】（取印枭比劫食伤）
         *   从弱状态，力量过于衰弱，无法生助和扶持，只宜克不宜生，用神为【火、土、金】（取食伤财才官杀）
         */
        $riganWuxing = $this->wx[$tiangan[2]];
        $wangshuaifen = 0;
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($Horoscope->param['canggan'][$v1] as $k2 => $v2)
            {
                if ($this->wx[$v2] === $riganWuxing)
                {
                    if ($k2 === 0)
                    {
                        $wangshuaifen += 10;
                    } else
                    {
                        $wangshuaifen += 3;
                    }
                    // 印本气根3
                    if ($Horoscope->param['shishen'][$v2][$tiangan[2]] === '正印')
                    {
                        $wangshuaifen += 3;
                    }
                    // 本气根在月令+3
                    if ($k1 === 1)
                    {
                        $wangshuaifen += 3;
                    } elseif ($k1 === 0)
                    {
                        $wangshuaifen--;
                    }
                }
                // 天干比劫、正印3，偏印2
                if (in_array($Horoscope->param['shishen'][$v2][$tiangan[2]], ['比肩', '劫财', '正印'], true))
                {
                    $wangshuaifen += 3;
                } elseif ($Horoscope->param['shishen'][$v2][$tiangan[2]] === '偏印')
                {
                    $wangshuaifen += 3;
                }
            }
        }
        $wuxingColor = [
            '木' => '#5BBB87',
            '火' => '#EC8337',
            '土' => '#C5C0C0',
            '金' => '#FDC756',
            '水' => '#5F7CEE',
            '甲' => '#5BBB87', '乙' => '#5BBB87',
            '丙' => '#EC8337', '丁' => '#EC8337',
            '戊' => '#C5C0C0', '己' => '#C5C0C0',
            '庚' => '#FDC756', '辛' => '#FDC756',
            '壬' => '#5F7CEE', '癸' => '#5F7CEE',
            '子' => '#5F7CEE', '丑' => '#C5C0C0',
            '寅' => '#5BBB87', '卯' => '#5BBB87',
            '辰' => '#C5C0C0', '巳' => '#EC8337',
            '午' => '#EC8337', '未' => '#C5C0C0',
            '申' => '#FDC756', '酉' => '#FDC756',
            '戌' => '#C5C0C0', '亥' => '#5F7CEE'
        ];

        // 0=>从弱,1=>身弱,2=>身强,3=>从强
        $wangshuaiYongshen = [
            0 => ['食神' => 7, '伤官' => 6, '正财' => 7, '偏财' => 7, '正官' => 7, '七杀' => 5], // 食7伤6财7才7官7杀5
            1 => ['正印' => 8, '偏印' => 6, '比肩' => 7, '劫财' => 7], // 印8枭6比7劫7
            2 => ['正官' => 8, '七杀' => 6, '正财' => 7, '偏财' => 8, '食神' => 7, '伤官' => 6], // 官8杀6财7才8食7伤6
            3 => ['正印' => 7, '偏印' => 0, '比肩' => 6, '劫财' => 7, '食神' => 8, '伤官' => 6], // 印7枭6比7劫6食8伤6
        ];
        //3分及以下，且日干为阴干，从弱（取食伤财才官杀）   (当前配置 0为阳干，1为阴干)
        if ($wangshuaifen <= 3 && $this->yy[$tiangan[2]] === 1)
        {
            $state = 0;
            $txt = '你的日主处于从弱状态，力量过于衰弱，无法生助和扶持，只宜克不宜生，用神为';
        } //13分以下，身弱（取印枭比劫）
        elseif ($wangshuaifen <= 13)
        {
            $state = 1;
            $txt = '你的日主处于身弱状态，优先补足力量，喜欢生自己和扶持自己的五行，用神为';
        } // 13分及其以上，身强（取官杀财才食伤）
        elseif ($wangshuaifen <= 30)
        {
            $state = 2;
            $txt = '你的日主处于身旺状态，可以胜任财官，喜欢跟自己相克、消耗自己力量的五行，用神为';
        } //30分及以上，从强（取印枭比劫食伤）
        else
        {
            $state = 3;
            $txt = '你的日主处于从旺状态，力量过于强旺，此时只宜生不宜克，用神为';
        }
        $ss = $wangshuaiYongshen[$state];
        $res['wangshuai']['content'] .= $txt;
        $wxGanZhi = [
            '甲' => ['寅'],
            '乙' => ['卯'],
            '丙' => ['巳'],
            '丁' => ['午'],
            '戊' => ['辰', '戌'],
            '己' => ['丑', '未'],
            '庚' => ['申'],
            '辛' => ['酉'],
            '壬' => ['亥'],
            '癸' => ['子'],
        ];
        $css = count($ss);
        $n = 0;
        foreach ($ss as $k1 => $v1)
        {
            $n++;
            $yongshenGan = $this->shishens[$tiangan[2]][$k1];
            $yongshenWx = $this->wx[$yongshenGan];
            // 用神干支分
            $yongshenFen['tiangan'][$yongshenGan] += $v1;
            foreach ($wxGanZhi[$yongshenGan] as $k2 => $v2)
            {
                $yongshenFen['dizhi'][$v2] += $v1;
            }
            // 过滤同五行的十神
            if ($n % 2 === 1)
            {
                $res['wangshuai']['tag_list'][] = ['name' => $yongshenWx, 'color' => $wuxingColor[$yongshenWx]];
                $res['wangshuai']['content'] .= $yongshenWx;

            }
            if ($n === $css - 1)
            {
                $res['wangshuai']['content'] .= '。';
            } elseif ($n % 2 === 1)
            {
                $res['wangshuai']['content'] .= '、';
            }
        }

        /**
         * 调候
         * 1、2、3拼接
         * 1、调候法就是计算你出生时的季节气候，用五行来补足气候的不足，给你创造更好的生长环境。
         * 2、你是生在 【立春】（检测其出生的节气并输出） 后的 【甲木】（检测其日干并输出），首先用【庚金】（表格内第一行）调节，其次用【戊土】和【丙火】（表格内第二行），再次用【己土】和【丁火】（表内第三行，无则本句不写）。
         * 3、你的八字当中有很好的调候用神，气候环境良好，容易有富贵有成就。（检测，原局天干出现调候用神且其分数和大于等于10）
         * 你的八字当中有调候用神，气候环境不错，有机会取得富贵和成就。（检测，原局天干出现调候用神）
         * 你的八字当中调候用神不太明显，需要等运势补足，在用神到来的大运或流年更易取得成就。（检测，原局天干没有调候用神）
         */
        // [日干][月支] 0=>10分,1=>6分,2=>4分
        $diaohou = [
            '甲' => [
                '寅' => [
                    ['丙'], ['癸'], []
                ],
                '卯' => [
                    ['庚'], ['丙', '戊'], ['丁', '己']
                ],
                '辰' => [
                    ['庚'], ['丁', '壬'], []
                ],
                '巳' => [
                    ['癸'], ['丁', '庚'], []
                ],
                '午' => [
                    ['癸'], ['丁', '庚'], []
                ],
                '未' => [
                    ['癸'], ['丁', '庚'], []
                ],
                '申' => [
                    ['庚'], ['丁', '壬'], []
                ],
                '酉' => [
                    ['庚'], ['丁', '丙'], []
                ],
                '戌' => [
                    ['庚'], ['甲', '壬'], ['丁', '癸']
                ],
                '亥' => [
                    ['庚'], ['丁', '戊'], ['丙']
                ],
                '子' => [
                    ['丁'], ['庚', '丙'], []
                ],
                '丑' => [
                    ['丁'], ['庚', '丙'], []
                ],
            ],
            '乙' => [
                '寅' => [
                    ['丙'], ['癸'], []
                ],
                '卯' => [
                    ['丙'], ['癸'], []
                ],
                '辰' => [
                    ['癸'], ['丙', '戊'], []
                ],
                '巳' => [
                    ['癸'], [], []
                ],
                '午' => [
                    ['癸'], ['丙'], []
                ],
                '未' => [
                    ['癸'], ['丙'], []
                ],
                '申' => [
                    ['丙'], ['癸', '己'], []
                ],
                '酉' => [
                    ['癸'], ['丙', '丁'], []
                ],
                '戌' => [
                    ['癸'], ['辛'], []
                ],
                '亥' => [
                    ['丙'], ['戊'], []
                ],
                '子' => [
                    ['丙'], [], []
                ],
                '丑' => [
                    ['丙'], [], []
                ],
            ],
            '丙' => [
                '寅' => [
                    ['壬'], ['庚'], []
                ],
                '卯' => [
                    ['壬'], ['己'], []
                ],
                '辰' => [
                    ['壬'], ['甲'], []
                ],
                '巳' => [
                    ['壬'], ['庚', '癸'], []
                ],
                '午' => [
                    ['壬'], ['庚'], []
                ],
                '未' => [
                    ['壬'], ['庚'], []
                ],
                '申' => [
                    ['壬'], ['戊'], []
                ],
                '酉' => [
                    ['壬'], ['癸'], []
                ],
                '戌' => [
                    ['甲'], ['壬'], []
                ],
                '亥' => [
                    ['甲'], ['戊', '庚'], ['壬']
                ],
                '子' => [
                    ['壬'], ['戊', '己'], []
                ],
                '丑' => [
                    ['壬'], ['甲'], []
                ],
            ],
            '丁' => [
                '寅' => [
                    ['甲'], ['庚'], []
                ],
                '卯' => [
                    ['庚'], ['甲'], []
                ],
                '辰' => [
                    ['甲'], ['庚'], []
                ],
                '巳' => [
                    ['甲'], ['庚'], []
                ],
                '午' => [
                    ['壬'], ['庚', '癸'], []
                ],
                '未' => [
                    ['甲'], ['壬', '庚'], []
                ],
                '申' => [
                    ['甲'], ['庚', '丙'], ['戊']
                ],
                '酉' => [
                    ['甲'], ['庚', '丙'], ['戊']
                ],
                '戌' => [
                    ['甲'], ['庚'], ['戊']
                ],
                '亥' => [
                    ['甲'], ['庚'], []
                ],
                '子' => [
                    ['甲'], ['庚'], []
                ],
                '丑' => [
                    ['甲'], ['庚'], []
                ],
            ],
            '戊' => [
                '寅' => [
                    ['丙'], ['甲', '癸'], []
                ],
                '卯' => [
                    ['丙'], ['甲', '癸'], []
                ],
                '辰' => [
                    ['甲'], ['丙', '癸'], []
                ],
                '巳' => [
                    ['甲'], ['丙', '癸'], []
                ],
                '午' => [
                    ['壬'], ['甲', '丙'], []
                ],
                '未' => [
                    ['癸'], ['丙', '甲'], []
                ],
                '申' => [
                    ['丙'], ['癸', '甲'], []
                ],
                '酉' => [
                    ['丙'], ['癸'], []
                ],
                '戌' => [
                    ['甲'], ['丙', '癸'], []
                ],
                '亥' => [
                    ['甲'], ['丙'], []
                ],
                '子' => [
                    ['丙'], ['甲'], []
                ],
                '丑' => [
                    ['丙'], ['甲'], []
                ],
            ],
            '己' => [
                '寅' => [
                    ['丙'], ['庚', '甲'], []
                ],
                '卯' => [
                    ['甲'], ['丙', '癸'], []
                ],
                '辰' => [
                    ['丙'], ['癸', '甲'], []
                ],
                '巳' => [
                    ['癸'], ['丙'], []
                ],
                '午' => [
                    ['癸'], ['丙'], []
                ],
                '未' => [
                    ['癸'], ['丙'], []
                ],
                '申' => [
                    ['丙'], ['癸'], []
                ],
                '酉' => [
                    ['丙'], ['癸'], []
                ],
                '戌' => [
                    ['甲'], ['丙', '癸'], []
                ],
                '亥' => [
                    ['丙'], ['甲', '戊'], []
                ],
                '子' => [
                    ['丙'], ['甲', '戊'], []
                ],
                '丑' => [
                    ['丙'], ['甲', '戊'], []
                ],
            ],
            '庚' => [
                '寅' => [
                    ['戊'], ['甲', '丙'], ['壬', '丁']
                ],
                '卯' => [
                    ['丁'], ['甲', '丙'], ['庚']
                ],
                '辰' => [
                    ['甲'], ['丁', '壬'], ['癸']
                ],
                '巳' => [
                    ['壬'], ['戊', '丙'], ['丁']
                ],
                '午' => [
                    ['壬'], ['癸'], []
                ],
                '未' => [
                    ['丁'], ['甲'], []
                ],
                '申' => [
                    ['丁'], ['甲'], []
                ],
                '酉' => [
                    ['丁'], ['甲', '丙'], []
                ],
                '戌' => [
                    ['甲'], ['壬'], []
                ],
                '亥' => [
                    ['丁'], ['丙'], []
                ],
                '子' => [
                    ['丁'], ['甲', '丙'], []
                ],
                '丑' => [
                    ['丙'], ['丁', '甲'], []
                ],
            ],
            '辛' => [
                '寅' => [
                    ['己'], ['壬', '庚'], []
                ],
                '卯' => [
                    ['壬'], ['甲'], []
                ],
                '辰' => [
                    ['壬'], ['甲'], []
                ],
                '巳' => [
                    ['壬'], ['甲'], ['癸']
                ],
                '午' => [
                    ['壬'], ['己', '癸'], []
                ],
                '未' => [
                    ['壬'], ['庚', '甲'], []
                ],
                '申' => [
                    ['壬'], ['甲', '戊'], []
                ],
                '酉' => [
                    ['壬'], ['甲'], []
                ],
                '戌' => [
                    ['壬'], ['甲'], []
                ],
                '亥' => [
                    ['壬'], ['丙'], []
                ],
                '子' => [
                    ['丙'], ['戊', '壬'], ['甲']
                ],
                '丑' => [
                    ['丙'], ['壬', '戊'], ['己']
                ],
            ],
            '壬' => [
                '寅' => [
                    ['庚'], ['丙', '戊'], []
                ],
                '卯' => [
                    ['戊'], ['辛', '庚'], []
                ],
                '辰' => [
                    ['甲'], ['庚'], []
                ],
                '巳' => [
                    ['壬'], ['辛', '庚'], ['癸']
                ],
                '午' => [
                    ['癸'], ['庚', '辛'], []
                ],
                '未' => [
                    ['辛'], ['甲'], []
                ],
                '申' => [
                    ['戊'], ['丁'], []
                ],
                '酉' => [
                    ['甲'], ['庚'], []
                ],
                '戌' => [
                    ['甲'], ['丙'], []
                ],
                '亥' => [
                    ['戊'], ['丙', '庚'], []
                ],
                '子' => [
                    ['戊'], ['丙'], []
                ],
                '丑' => [
                    ['丙'], ['丁'], ['甲']
                ],
            ],
            '癸' => [
                '寅' => [
                    ['辛'], ['丙'], []
                ],
                '卯' => [
                    ['庚'], ['辛'], []
                ],
                '辰' => [
                    ['丙'], ['辛', '甲'], []
                ],
                '巳' => [
                    ['辛'], [], []
                ],
                '午' => [
                    ['庚'], ['癸', '辛'], ['壬']
                ],
                '未' => [
                    ['庚'], ['辛', '壬'], ['癸']
                ],
                '申' => [
                    ['丁'], [], []
                ],
                '酉' => [
                    ['辛'], ['丙'], []
                ],
                '戌' => [
                    ['辛'], ['甲', '壬'], ['癸']
                ],
                '亥' => [
                    ['庚'], ['辛', '戊'], ['丁']
                ],
                '子' => [
                    ['丙'], ['辛'], []
                ],
                '丑' => [
                    ['丙'], ['丁'], []
                ],
            ],
        ];
        $birthTime = strtotime($this->record['year'] . '-' . $this->record['month'] . '-' . $this->record['day'] . ' ' . $this->record['hour'] . ':' . $this->record['minute']);
        $birthTime -= $this->record['timezone'] * 3600 - $this->record['is_summer'] * 3600;
        $shengqianJie = (new SolarTerms())->where('time', '<', $birthTime)->order('time DESC')->find()->toArray();
        $shengqianJieName = $Horoscope->getJieQiName($shengqianJie['deg']);
        $res['diaohou']['content'] .= '你是生在' . $shengqianJieName . '后的' . $bazi[5] . $this->wx[$bazi[5]] . '，';
        $diaohouFen = 0;
        foreach ($diaohou[$tiangan[2]][$dizhi[1]] as $k1 => $v1)
        {
            $cv2 = count($v1);
            if ($cv2 > 0)
            {
                if ($k1 === 0)
                {
                    $res['diaohou']['content'] .= '首先用';
                } elseif ($k1 === 1)
                {
                    $res['diaohou']['content'] .= '其次用';
                } else
                {
                    $res['diaohou']['content'] .= '再次';
                }
                foreach ($v1 as $k2 => $v2)
                {
                    if ($k2 > 0)
                    {
                        $res['diaohou']['content'] .= '和';
                    }
                    $res['diaohou']['content'] .= $v2 . $this->wx[$v2];

                    $res['diaohou']['tag_list'][] = ['name' => $this->wx[$v2], 'color' => $wuxingColor[$this->wx[$v2]]];

                    if ($k2 === $cv2 - 1)
                    {
                        if ($k1 === 0)
                        {
                            $res['diaohou']['content'] .= '调节';
                        }
                        if (isset($diaohou[$tiangan[2]][$dizhi[1]][$k1 + 1]) && !empty($diaohou[$tiangan[2]][$dizhi[1]][$k1 + 1]))
                        {
                            $res['diaohou']['content'] .= '，';
                        }
                    }
                    if ($k1 === 0)
                    {
                        $add = 10;
                    } elseif ($k1 === 1)
                    {
                        $add = 6;
                    } else
                    {
                        $add = 4;
                    }
                    $diaohouFen += $add;
                    // 用神干支分 地支用神分为天干的0.7倍
                    $yongshenFen['tiangan'][$v2] += $add;
                    foreach ($wxGanZhi[$v2] as $k3 => $v3)
                    {
                        $yongshenFen['dizhi'][$v3] += $add * 0.7;
                    }
                }
            }
        }
        $res['diaohou']['content'] .= '。';
        if ($diaohouFen >= 10)
        {
            $res['diaohou']['content'] .= '你的八字当中有很好的调候用神，气候环境良好，容易有富贵有成就。';
        } elseif ($diaohouFen > 0)
        {
            $res['diaohou']['content'] .= '你的八字当中有调候用神，气候环境不错，有机会取得富贵和成就。';
        } else
        {
            $res['diaohou']['content'] .= '你的八字当中调候用神不太明显，需要等运势补足，在用神到来的大运或流年更易取得成就。';
        }

        /**
         * 病药
         * 拼接1+234择一
         * 1、病药法是寻找八字当中的问题（病），针对性的寻求解决问题的字或五行（药）。
         * 2、你的八字病在
         *  日主为金水木火时，印星透干且有本气根，同时，印星透干+本气有三个或以上时
         *   土重金埋，需用木来疏土，所以用神为 甲、乙、寅、卯
         *   金多水浊，需用火来克金，所以用神为 丙、丁、巳、午
         *   水大木漂，需用土来止水，所以用神为戊、己、戌、未
         *   木多火塞，需用金来克木，所以用神为庚、辛、申、酉
         * 3、你的八字病在
         *  检测天干地支有无财官印食受克的结构
         *     1、干与干只计算同性克 取合凶神、正克凶神、正生吉神的天干
         *     2、支与支需有刑冲穿合拱的关系，只计算本气和土藏气 取合凶、克凶、生吉神的天干的本气根，且该根需合拱吉神支或合拱刑冲穿凶神支
         *     3、干与支需为同柱，天干可克地支中的藏干，地支克天干必须是地支本气
         *         如天干为凶神，同1
         *         如地支本气为凶神，同2
         *   官星受克，需用印星或财星来保护或生助官星，所以用神为庚、辛、申（所得保护字）
         *   财星受克，需用食伤或者官杀来保护或生助财星，
         *   食神受克，需用比劫或者财星来生助或保护食神，
         *   印星受克，需用官杀或者比劫来生助或保护印星，
         *   日主受克，需用食神或正印来保护或生助日主，
         * 4、你的八字没有明显的病，所以用此法并未取到合适的用神，可参考别的方法。
         */
        $yinxingGan1 = $this->shishens[$tiangan[2]]['正印'];
        $yinxingGan2 = $this->shishens[$tiangan[2]]['偏印'];
        $isZhengguanshouke = false; // 是否正官受克（找出不能作为最佳用神的五行）
        $isShishenshouke = false; // 是否食神受克（找出不能作为最佳用神的五行）
        $touganNum = 0;
        $yinxingTouGan = false;
        $yinxingBenqi = false;
        foreach ($tiangan as $k1 => $v1)
        {
            if ($k1 === 2) continue;
            if ($v1 === $yinxingGan1 || $v1 === $yinxingGan2)
            {
                $touganNum++;
                $yinxingTouGan = true;
            }
        }
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($Horoscope->param['canggan'][$v1] as $k2 => $v2)
            {
                if ($v2 === $yinxingGan1 || $v2 === $yinxingGan2)
                {
                    if ($k2 === 0)
                    {
                        $touganNum++;
                        $yinxingBenqi = true;
                    }
                }
            }
        }
        // 日主为金水木火时，印星透干且有本气根，同时，印星透干+本气有三个或以上时
        if ($yinxingTouGan && $yinxingBenqi && $touganNum >= 3 && in_array($riganWuxing, ['金', '水', '木', '火'], true))
        {
            switch ($riganWuxing)
            {
                case '火':
                    $yongshenGan1 = '甲';
                    $yongshenGan2 = '乙';
                    $res['bingyao']['tag_list'] = [
                        ['name' => '庚', 'color' => $wuxingColor['金']],
                        ['name' => '辛', 'color' => $wuxingColor['金']],
                        ['name' => '申', 'color' => $wuxingColor['金']],
                        ['name' => '酉', 'color' => $wuxingColor['金']],
                    ];
                    $res['bingyao']['content'] .= '你的八字病在木多火塞，需用金来克木，所以用神为庚金、辛金、申金、酉金';
                    break;
                case '金':
                    $yongshenGan1 = '丙';
                    $yongshenGan2 = '丁';
                    $res['bingyao']['tag_list'] = [
                        ['name' => '甲', 'color' => $wuxingColor['木']],
                        ['name' => '乙', 'color' => $wuxingColor['木']],
                        ['name' => '寅', 'color' => $wuxingColor['木']],
                        ['name' => '卯', 'color' => $wuxingColor['木']],
                    ];
                    $res['bingyao']['content'] .= '你的八字病在土重金埋，需用木来疏土，所以用神为甲木、乙木、寅木、卯木';
                    break;
                case '水':
                    $yongshenGan1 = '戊';
                    $yongshenGan2 = '己';
                    $res['bingyao']['tag_list'] = [
                        ['name' => '丙', 'color' => $wuxingColor['火']],
                        ['name' => '丁', 'color' => $wuxingColor['火']],
                        ['name' => '巳', 'color' => $wuxingColor['火']],
                        ['name' => '午', 'color' => $wuxingColor['火']],
                    ];
                    $res['bingyao']['content'] .= '你的八字病在金多水浊，需用火来克金，所以用神为丙火、丁火、巳火、午火';
                    break;
                case '木':
                    $yongshenGan1 = '庚';
                    $yongshenGan2 = '辛';
                    $res['bingyao']['tag_list'] = [
                        ['name' => '戊', 'color' => $wuxingColor['土']],
                        ['name' => '己', 'color' => $wuxingColor['土']],
                        ['name' => '戌', 'color' => $wuxingColor['土']],
                        ['name' => '未', 'color' => $wuxingColor['土']],
                    ];
                    $res['bingyao']['content'] .= '你的八字病在水大木漂，需用土来止水，所以用神为戊土、己土、戌土、未土';
                    break;
            }
        }
        // 检测天干地支有无财官印食受克的结构
        if (empty($res['bingyao']['tag_list']))
        {
            $shoukeJishen = [];
            // 财官印食受克的对应组合
            $zuhe = [
                '正财' => '劫财',
                '偏财' => '比肩',
                '正官' => '伤官',
                '正印' => '正财',
                '食神' => '偏印',
            ];
            // 甲己相合为土，乙庚相合为金，丙辛相合为水，丁壬相合为木，戊癸相合为火。
            $tianganHeList = [
                '甲' => '己',
                '乙' => '庚',
                '丙' => '辛',
                '丁' => '壬',
                '戊' => '癸',
                '己' => '甲',
                '庚' => '乙',
                '辛' => '丙',
                '壬' => '丁',
                '癸' => '戊',
            ];
            // 天干被地支本气根正克
            $zhibenqiKeList = [
                '甲' => ['申'],
                '乙' => ['酉'],
                '丙' => ['亥'],
                '丁' => ['癸'],
                '戊' => ['寅'],
                '己' => ['卯'],
                '庚' => ['乙'],
                '辛' => ['巳'],
                '壬' => ['辰', '戌'],//
                '癸' => ['丑', '未'],//
            ];
            // 检测是否有有官食受克
            // 四柱
            for ($i = 0; $i < 4; $i++)
            {
                // 四柱天干
                $gan1 = $tiangan[$i];
                // 四柱地支
                $zhi1 = $dizhi[$i];
                // 天干十神
                $gan1Shishen = $Horoscope->param['shishen'][$gan1][$tiangan[2]];
                $zhi1BenqiShishen = '';
                // 检查七杀日干
                if ($Horoscope->param['shishen'][$gan1][$tiangan[2]] === '七杀')
                {
                    $yongshenGan1 = $this->shishens[$tiangan[2]]['食神'];
                    $yongshenGan2 = $this->shishens[$tiangan[2]]['正印'];
                    $res['bingyao']['tag_list'] = [
                        ['name' => $this->wx[$yongshenGan1], 'color' => $wuxingColor[$this->wx[$yongshenGan1]]],
                        ['name' => $this->wx[$yongshenGan2], 'color' => $wuxingColor[$this->wx[$yongshenGan2]]],
                    ];
                    $res['bingyao']['content'] .= '你的八字病在日主受克，需用食神或正印来保护或生助日主，所以用神为' . $yongshenGan1 . '、' . $yongshenGan2 . '。';
                    break;
                }
                // 检测异柱干支组合
                for ($j = 0; $j < 4; $j++)
                {
                    $gan2 = $tiangan[$j];
                    $zhi2 = $dizhi[$j];
                    $zhi2benqi = $Horoscope->param['canggan'][$zhi2][0];
                    $gan2Shishen = $Horoscope->param['shishen'][$gan2][$tiangan[2]];
                    $zhi2BenqiShishen = $Horoscope->param['shishen'][$zhi2benqi][$tiangan[2]];
                    // 八字中出现吉神受克组合（干对干、支对支、同柱干支）
                    if ($i !== $j)
                    {
                        // 干对干 (干与干只计算同性克 取合凶神、正克凶神、正生吉神的天干)
                        if (isset($zuhe[$gan1Shishen]) && $zuhe[$gan1Shishen] === $gan2Shishen && $this->yy[$gan1] === $this->yy[$gan2])
                        {
                            if (in_array($gan1Shishen, ['正财', '偏财', '正官', '七杀', '食神', '正印', '偏印'], true))
                            {
                                $yongshenGan1 = $tianganHeList[$gan2];
                                $yongshenGan2 = $this->beiKe[$gan2][$this->yy[$gan2]];
                                $yongshenGan3 = $this->beiSheng[$gan1][$this->yy[$gan2]];
                                $res['bingyao']['tag_list'] = [
                                    ['name' => $this->wx[$yongshenGan1], 'color' => $wuxingColor[$this->wx[$yongshenGan1]]],
                                    ['name' => $this->wx[$yongshenGan2], 'color' => $wuxingColor[$this->wx[$yongshenGan2]]],
                                    ['name' => $this->wx[$yongshenGan3], 'color' => $wuxingColor[$this->wx[$yongshenGan3]]],
                                ];
                                switch ($gan1Shishen)
                                {
                                    case '正财':
                                    case '偏财':
                                        $res['bingyao']['content'] .= '你的八字病在财星受克，需用食伤或者官杀来保护或生助财星';
                                        break;
                                    case '正官':
                                        $isZhengguanshouke = true;
                                    case '七杀':
                                        $res['bingyao']['content'] .= '你的八字病在官星受克，需用印星或财星来保护或生助官星';
                                        break;
                                    case '食神':
                                        $isShishenshouke = true;
                                        $res['bingyao']['content'] .= '你的八字病在食神受克，需用比劫或者财星来生助或保护食神';
                                        break;
                                    case '正印':
                                    case '偏印':
                                        $res['bingyao']['content'] .= '你的八字病在印星受克，需用官杀或者比劫来生助或保护印星';
                                        break;
                                }
                                $res['bingyao']['content'] .= '，所以用神为' . $yongshenGan1 . '、' . $yongshenGan2 . '、' . $yongshenGan3 . '。';
                                break 2;
                            }
                        }
                        if (($Horoscope->is_xing($zhi1, $zhi2)
                            || $Horoscope->is_liuchong($zhi1, $zhi2)
                            || $Horoscope->is_liuhai($zhi1, $zhi2)
                            || $Horoscope->is_liuhe($zhi1, $zhi2)
                            || $Horoscope->is_anhe($zhi1, $zhi2)
                            || $Horoscope->is_gong($zhi1, $zhi2)))
                        {
                            // 遍历地支藏干1
                            foreach ($Horoscope->param['canggan'][$zhi1] as $k1 => $v1)
                            {
                                // 遍历地支藏干2
                                foreach ($Horoscope->param['canggan'][$zhi2] as $k2 => $v2)
                                {
                                    // 只计算本气和土藏气
                                    if (($k1 === 0 || in_array($zhi1, ['辰', '戌', '丑', '未'], true)) && ($k2 === 0 || in_array($zhi2, ['辰', '戌', '丑', '未'], true)))
                                    {
                                        $zhi1CangganShishen = $Horoscope->param['shishen'][$v1][$tiangan[2]];
                                        $zhi2CangganShishen = $Horoscope->param['shishen'][$v2][$tiangan[2]];
                                        // 吉神为
                                        if (isset($zuhe[$zhi1CangganShishen]) && $zuhe[$zhi1CangganShishen] === $zhi2CangganShishen)
                                        {
                                            // TODO 取克凶的天干、本气根克凶的地支、本气根合凶的地支、本气根生吉神的地支
                                            $yongshenGan2 = $this->beiKe[$v2][$this->yy[$v2]];// 取克凶的天干
                                            // 本气根克凶的地支
                                            // 本气根合凶的地支
                                            // 本气根生吉神的地支
                                            $yongshenGan1 = $tianganHeList[$v2];
                                            $yongshenGan3 = $this->beiSheng[$v1][$this->yy[$v2]];
                                            $res['bingyao']['tag_list'] = [
                                                ['name' => $this->wx[$yongshenGan1], 'color' => $wuxingColor[$yongshenGan1]],
                                                ['name' => $this->wx[$yongshenGan2], 'color' => $wuxingColor[$yongshenGan2]],
                                                ['name' => $this->wx[$yongshenGan3], 'color' => $wuxingColor[$yongshenGan3]],
                                            ];
                                            switch ($zhi1CangganShishen)
                                            {
                                                case '正财':
                                                case '偏财':
                                                    $res['bingyao']['content'] .= '你的八字病在财星受克，需用食伤或者官杀来保护或生助财星';
                                                    break;
                                                case '正官':
                                                    $isZhengguanshouke = true;
                                                case '七杀':
                                                    $res['bingyao']['content'] .= '你的八字病在官星受克，需用印星或财星来保护或生助官星';
                                                    break;
                                                case '食神':
                                                    $isShishenshouke = true;
                                                    $res['bingyao']['content'] .= '你的八字病在食神受克，需用比劫或者财星来生助或保护食神';
                                                    break;
                                                case '正印':
                                                case '偏印':
                                                    $res['bingyao']['content'] .= '你的八字病在印星受克，需用官杀或者比劫来生助或保护印星';
                                                    break;
                                            }
                                            $res['bingyao']['content'] .= '，所以用神为' . $yongshenGan1 . '、' . $yongshenGan2 . '、' . $yongshenGan3 . '。';
                                            break 4;
                                        } elseif (isset($zuhe[$zhi2CangganShishen]) && $zuhe[$zhi2CangganShishen] === $zhi1CangganShishen)
                                        {
                                            // TODO 取克凶的天干、本气根克凶的地支、本气根合凶的地支、本气根生吉神的地支
                                            $yongshenGan1 = $tianganHeList[$v1];
                                            $yongshenGan2 = $this->beiKe[$v1][$this->yy[$v1]];
                                            $yongshenGan3 = $this->beiSheng[$v2][$this->yy[$v1]];
                                            $res['bingyao']['tag_list'] = [
                                                ['name' => $this->wx[$yongshenGan1], 'color' => $wuxingColor[$this->wx[$yongshenGan1]]],
                                                ['name' => $this->wx[$yongshenGan2], 'color' => $wuxingColor[$this->wx[$yongshenGan2]]],
                                                ['name' => $this->wx[$yongshenGan3], 'color' => $wuxingColor[$this->wx[$yongshenGan3]]],
                                            ];
                                            switch ($zhi2CangganShishen)
                                            {
                                                case '正财':
                                                case '偏财':
                                                    $res['bingyao']['content'] .= '你的八字病在财星受克，需用食伤或者官杀来保护或生助财星';
                                                    break;
                                                case '正官':
                                                case '七杀':
                                                    $res['bingyao']['content'] .= '你的八字病在官星受克，需用印星或财星来保护或生助官星';
                                                    break;
                                                case '食神':
                                                    $res['bingyao']['content'] .= '你的八字病在食神受克，需用比劫或者财星来生助或保护食神';
                                                    break;
                                                case '正印':
                                                case '偏印':
                                                    $res['bingyao']['content'] .= '你的八字病在印星受克，需用官杀或者比劫来生助或保护印星';
                                                    break;
                                            }
                                            $res['bingyao']['content'] .= '，所以用神为' . $yongshenGan1 . '、' . $yongshenGan2 . '、' . $yongshenGan3 . '。';
                                            break 4;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                // 遍历地支藏干 判定
                foreach ($Horoscope->param['canggan'][$zhi1] as $k1 => $v1)
                {
                    $cangganShishen = $Horoscope->param['shishen'][$v1][$tiangan[2]];
                    if ($k1 === 0)
                    {
                        // 地支本气藏干十神
                        $zhi1BenqiShishen = $cangganShishen;
                    }
                    // 检查同柱 地支本气克天干 （地支克天干必须是地支本气）
                    if (isset($zuhe[$gan1Shishen]) && $zuhe[$gan1Shishen] === $cangganShishen && $k1 === 0)
                    {
                        // TODO 取克凶的天干、本气根克凶的地支、本气根合凶的地支、本气根生吉神的地支，且该根需合拱吉神支或合拱刑冲穿凶神支
                        if (in_array($zhi1BenqiShishen, ['正财', '偏财', '正官', '七杀', '食神', '正印', '偏印'], true))
                        {
                            $yongshenGan1 = $tianganHeList[$v1];
                            $yongshenGan2 = $this->beiKe[$v1][$this->yy[$v1]];
                            $yongshenGan3 = $this->beiSheng[$gan1][$this->yy[$v1]];
                            $res['bingyao']['tag_list'] = [
                                ['name' => $this->wx[$yongshenGan1], 'color' => $wuxingColor[$this->wx[$yongshenGan1]]],
                                ['name' => $this->wx[$yongshenGan2], 'color' => $wuxingColor[$this->wx[$yongshenGan2]]],
                                ['name' => $this->wx[$yongshenGan3], 'color' => $wuxingColor[$this->wx[$yongshenGan3]]],
                            ];
                            switch ($gan1Shishen)
                            {
                                case '正财':
                                case '偏财':
                                    $res['bingyao']['content'] .= '你的八字病在财星受克，需用食伤或者官杀来保护或生助财星';
                                    break;
                                case '正官':
                                    $isZhengguanshouke = true;
                                case '七杀':
                                    $res['bingyao']['content'] .= '你的八字病在官星受克，需用印星或财星来保护或生助官星';
                                    break;
                                case '食神':
                                    $isShishenshouke = true;
                                    $res['bingyao']['content'] .= '你的八字病在食神受克，需用比劫或者财星来生助或保护食神';
                                    break;
                                case '正印':
                                case '偏印':
                                    $res['bingyao']['content'] .= '你的八字病在印星受克，需用官杀或者比劫来生助或保护印星';
                                    break;
                            }
                            $res['bingyao']['content'] .= '，所以用神为' . $yongshenGan1 . '、' . $yongshenGan2 . '、' . $yongshenGan3 . '。';
                            break 2;
                        }
                    } // 天干克地支 （天干可克地支中的藏干）
                    elseif (isset($zuhe[$cangganShishen]) && $zuhe[$cangganShishen] === $gan1Shishen && $this->yy[$gan1] === $this->yy[$v1])
                    {
                        // 干与干只计算同性克 TODO 取克凶的天干、本气根克凶的地支、本气根合凶的地支、本气根生吉神的地支
                        $yongshenGan1 = $tianganHeList[$gan1];
                        $yongshenGan2 = $this->beiKe[$gan1][$this->yy[$gan1]];
                        $yongshenGan3 = $this->beiSheng[$v1][$this->yy[$gan1]];
                        $res['bingyao']['tag_list'] = [
                            ['name' => $this->wx[$yongshenGan1], 'color' => $wuxingColor[$this->wx[$yongshenGan1]]],
                            ['name' => $this->wx[$yongshenGan2], 'color' => $wuxingColor[$this->wx[$yongshenGan2]]],
                            ['name' => $this->wx[$yongshenGan3], 'color' => $wuxingColor[$this->wx[$yongshenGan3]]],
                        ];
                        switch ($cangganShishen)
                        {
                            case '正财':
                            case '偏财':
                                $res['bingyao']['content'] .= '你的八字病在财星受克，需用食伤或者官杀来保护或生助财星';
                                break;
                            case '正官':
                                $isZhengguanshouke = true;
                            case '七杀':
                                $res['bingyao']['content'] .= '你的八字病在官星受克，需用印星或财星来保护或生助官星';
                                break;
                            case '食神':
                                $isShishenshouke = true;
                                $res['bingyao']['content'] .= '你的八字病在食神受克，需用比劫或者财星来生助或保护食神';
                                break;
                            case '正印':
                            case '偏印':
                                $res['bingyao']['content'] .= '你的八字病在印星受克，需用官杀或者比劫来生助或保护印星';
                                break;
                        }
                        $res['bingyao']['content'] .= '，所以用神为' . $yongshenGan1 . '、' . $yongshenGan2 . '、' . $yongshenGan3 . '。';
                        break 2;
                    }
                }
            }
        }
        if (empty($res['bingyao']['tag_list']))
        {
            $res['bingyao']['content'] .= '你的八字没有明显的病，所以用此法并未取到合适的用神，可参考别的方法。';
        }
        // 用神干支分
        if (isset($yongshenGan1) && $yongshenGan1)
        {
            $yongshenFen['tiangan'][$yongshenGan1] += 8;
            foreach ($wxGanZhi[$yongshenGan1] as $k1 => $v1)
            {
                $yongshenFen['dizhi'][$v1] += 8;
            }
        }
        if (isset($yongshenGan2) && $yongshenGan2)
        {
            $yongshenFen['tiangan'][$yongshenGan2] += 8;
            foreach ($wxGanZhi[$yongshenGan2] as $k1 => $v1)
            {
                $yongshenFen['dizhi'][$v1] += 8;
            }
        }
        if (isset($yongshenGan3) && $yongshenGan3)
        {
            $yongshenFen['tiangan'][$yongshenGan3] += 8;
            foreach ($wxGanZhi[$yongshenGan3] as $k1 => $v1)
            {
                $yongshenFen['dizhi'][$v1] += 8;
            }
        }

        // 病药的判定里面，如果有官食受克，则克官食的伤食、枭印（天干+本气支，）评分-15，TODO 且不能作为最佳用神
        $feiZuijiaGanzhi = [];
        if ($isZhengguanshouke)
        {
            $shoukeGan = $this->shishens[$tiangan[2]]['正官'];
            $keGan = $this->beiKe[$shoukeGan];
            $yongshenFen['tiangan'][$keGan[0]] -= 15;
            $yongshenFen['tiangan'][$keGan[1]] -= 15;
            $feiZuijiaGanzhi = array_merge($feiZuijiaGanzhi, $keGan);
            foreach ($wxGanZhi[$shoukeGan] as $k1 => $v1)
            {
                $yongshenFen['dizhi'][$v1] -= 15;
                $feiZuijiaGanzhi[] = $v1;
            }
        }
        if ($isShishenshouke)
        {
            $shoukeGan = $this->shishens[$tiangan[2]]['食神'];
            $keGan = $this->beiKe[$shoukeGan];
            $yongshenFen['tiangan'][$keGan[0]] -= 15;
            $yongshenFen['tiangan'][$keGan[1]] -= 15;
            $feiZuijiaGanzhi = array_merge($feiZuijiaGanzhi, $keGan);
            foreach ($wxGanZhi[$shoukeGan] as $k1 => $v1)
            {
                $yongshenFen['dizhi'][$v1] -= 15;
                $feiZuijiaGanzhi[] = $v1;
            }
        }

        /**
         * 格局
         * 格局法是通过八字的月令格局来寻找所需的用神。你的格局是【正官格】（取格，不取细化后的格局，不带通变、杂气等字），【木、火】是促成和壮大格局的五行，即为你的格局用神。
         */
        $gejuFen = [];
        $gejuYongshen = $Horoscope->bazineige($bazi, $state, $ss);
        $res['geju']['content'] = '格局法是通过八字的月令格局来寻找所需的用神。你的格局是' . $gejuYongshen['geju'] . '，';
        $wxArr = [];
        foreach ($gejuYongshen['yongshen'] as $k1 => $v1)
        {
            $ssg = $this->shishens[$tiangan[2]][$k1];
            $wx = $this->wx[$ssg];
            if (!in_array($wx, $wxArr, true))
            {
                $wxArr[] = $wx;
                $res['geju']['tag_list'][] = [
                    'name' => $wx, 'color' => $wuxingColor[$wx],
                ];
            }
            // 用神干支分
            $yongshenFen['tiangan'][$ssg] += $v1;
            $gejuFen['tiangan'][$ssg] = 6;
            foreach ($wxGanZhi[$ssg] as $k2 => $v2)
            {
                $yongshenFen['dizhi'][$v2] += $v1;
                $gejuFen['dizhi'][$v2] = 6;
            }
        }
        $wxString = implode('、', $wxArr);
        $res['geju']['content'] .= $wxString . '是促成和壮大格局的五行，即为你的格局用神。';

        /**
         * 用神整合注意事项
         *  旺衰用神需取天干+本气地支（土的本气地支仅计算戌未），干支同分数
         *  调候用神以天干为主，但用神的本气地支也是用神，取值为天干用神的0.7倍（戊己本气支仅取戌未）
         *  病药用神按上面的计算选取
         *  格局用神干支并重，同分数
         *  各部分用神换算成具体干支，并按用神分相加，得一次用神分加一次，最终按分数计算其等级
         *  用神三级：15分及其以上
         *  用神二级：10分及其以上
         *  用神一级：1分及其以上
         */
        $yongshenzhenghe = [];
        foreach ($yongshenFen as $k1 => $v1)
        {
            foreach ($v1 as $k2 => $v2)
            {
                $s = 0;
                if ($v2 >= 15)
                {
                    $s = 3;
                } elseif ($v2 >= 10)
                {
                    $s = 2;
                } elseif ($v2 > 0)
                {
                    $s = 1;
                }
                if ($k1 === 'tiangan')
                {
                    $key2 = $k2 . $this->wx[$k2];
                } else
                {
                    $key2 = $k2 . $this->wx[$Horoscope->param['canggan'][$k2][0]];
                }
                $yongshenzhenghe[$k1][$key2] = $s;
            }
        }
        $res['yongshenzhenghe'] = $yongshenzhenghe;

        /**
         * 最大用神计算
         * 1，各方法所得的用神分进行叠加，计算各天干的用神分之和（格局用神各加6分，其余按之前逻辑）
         * 2，天干对应的本气地支，基础得分与天干得分相同，但如与原局冲穿刑且构成吉神受克组合，减去6分（如减分后得分为零保留1分）
         *    经过协商，改为 如与原局冲穿刑，减去3分（如减分后得分为零保留1分）
         * 3，如用神分不为零的干支在最好三年出现，每出现一次得分加10，在最差三年出现，每出现一次得分减5
         * 4，得分为零的干支在最好三年出现，一次加6，两次以上加15
         * 5，最后列出各干支最终得分，最高且在20以上为4级，10-20为3级，5-10为2级，5以下1级
         */
        foreach ($yongshenFen as $k1 => $v1)
        {
            foreach ($v1 as $k2 => $v2)
            {
                // 格局用神各加6分
                if (isset($gejuFen[$k1][$k2]))
                {
                    $yongshenFen[$k1][$k2] += $gejuFen[$k1][$k2];
                }
                if ($k1 === 'dizhi')
                {
                    // 如与原局冲穿刑，减去3分（如减分后得分为零保留1分）
                    foreach ($dizhi as $k3 => $v3)
                    {
                        if ($Horoscope->is_xing($v3, $v2)
                            || $Horoscope->is_liuchong($v3, $v2)
                            || $Horoscope->is_liuhai($v3, $v2))
                        {
                            $yongshenFen[$k1][$k2] -= 3;
                            if ($yongshenFen[$k1][$k2] < 1)
                            {
                                $yongshenFen[$k1][$k2] = 1;
                            }
                        }
                    }
                }
            }
        }
        $goodYearFen0Num = [];
        // 获取最好的年份干支
        if (isset($option['good_years']) && !empty($option['good_years']))
        {
            foreach ($option['good_years'] as $k1 => $v1)
            {
                $y_gan_zhi = $Horoscope->param['chinese_era'][$Horoscope->getYearStemBranche($v1)];
                // 流年干支
                $ln = [mb_substr($y_gan_zhi, 0, 1), mb_substr($y_gan_zhi, 1, 1)];
                if ($yongshenFen['tiangan'][$ln[0]] > 0)
                {
                    $yongshenFen['tiangan'][$ln[0]] += 10;
                }
                if ($yongshenFen['dizhi'][$ln[1]] > 0)
                {
                    $yongshenFen['dizhi'][$ln[1]] += 10;
                }
                if ($yongshenFen['tiangan'][$ln[0]] === 0)
                {
                    if (!isset($goodYearFen0Num[$ln[0]]))
                    {
                        $goodYearFen0Num[$ln[0]] = 0;
                    }
                    $goodYearFen0Num[$ln[0]]++;
                }
                if ($yongshenFen['dizhi'][$ln[1]] === 0)
                {
                    if (!isset($goodYearFen0Num[$ln[1]]))
                    {
                        $goodYearFen0Num[$ln[1]] = 0;
                    }
                    $goodYearFen0Num[$ln[1]]++;
                }
            }
        }
        if (!empty($goodYearFen0Num))
        {
            foreach ($goodYearFen0Num as $k1 => $v1)
            {
                if ($v1 >= 2)
                {
                    $add = 15;
                } else
                {
                    $add = 6;
                }
                isset($yongshenFen['tiangan'][$k1]) && $yongshenFen['tiangan'][$k1] += $add;
            }
        }
        // 获取最差的年份干支
        if (isset($option['bad_years']) && !empty($option['bad_years']))
        {
            foreach ($option['bad_years'] as $k1 => $v1)
            {
                $y_gan_zhi = $Horoscope->param['chinese_era'][$Horoscope->getYearStemBranche($v1)];
                // 流年干支
                $ln = [mb_substr($y_gan_zhi, 0, 1), mb_substr($y_gan_zhi, 1, 1)];
                if ($yongshenFen['tiangan'][$ln[0]] > 0)
                {
                    $yongshenFen['tiangan'][$ln[0]] -= 5;
                }
                if ($yongshenFen['dizhi'][$ln[1]] > 0)
                {
                    $yongshenFen['dizhi'][$ln[1]] -= 5;
                }
            }
        }
        /**
         * 最大用神 就是得分最高的用神，【庚金，癸水等】，
         * 方向是用神对应的方向【木东方火南方金西方水北方土中部】，
         * 颜色是五行对应的颜色，取名建议是五行对应的属性字【木】属性字，土属性字等
         */
        $maxTiangan = max($yongshenFen['tiangan']);
        $maxDizhi = max($yongshenFen['dizhi']);
        if ($maxTiangan >= $maxDizhi)
        {
            $maxYongshen = array_search($maxTiangan, $yongshenFen['tiangan'], true);
            $maxWx = $this->wx[$maxYongshen];
        } else
        {
            $maxYongshen = array_search($maxDizhi, $yongshenFen['dizhi'], true);
            $maxWx = $this->wx[$Horoscope->param['canggan'][$maxYongshen][0]];
        }
        $fangxiang = [
            '金' => '西方',
            '木' => '东方',
            '水' => '北方',
            '火' => '南方',
            '土' => '中部',
        ];
        // 木:绿色，火:红色，土:黄色，金:白色，水:蓝黑色
        $yanse = [
            '金' => '白色',
            '木' => '绿色',
            '水' => '蓝黑色',
            '火' => '红色',
            '土' => '黄色',
        ];
        $res['yongshen'] = $maxYongshen . $maxWx;
        $res['fangxiang'] = $fangxiang[$maxWx];
        $res['yanse'] = $yanse[$maxWx];
        $res['quming'] = $maxWx;

        return $res;
    }
}
